动态生成的DataTemplate,怎么为其的控件绑定事件
展开全部
代码数带并如下:薯迹
C# code?
1
2
3
4
5
6
7
8
9
10
11
12
string xaml1 = @"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'><StackPanel>
<ComboBox SelectionChanged='comboBox_SelectionChanged' Width='100'><ComboBoxItem Content='item1' /><ComboBoxItem Content='item2'/> </ComboBox>
</StackPanel>
<行岩/DataTemplate>";
DataTemplate dataTemplate = XamlReader.Parse(xaml1) as DataTemplate;
private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//......
}
C# code?
1
2
3
4
5
6
7
8
9
10
11
12
string xaml1 = @"<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'><StackPanel>
<ComboBox SelectionChanged='comboBox_SelectionChanged' Width='100'><ComboBoxItem Content='item1' /><ComboBoxItem Content='item2'/> </ComboBox>
</StackPanel>
<行岩/DataTemplate>";
DataTemplate dataTemplate = XamlReader.Parse(xaml1) as DataTemplate;
private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//......
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询