我有我的用户它由StackPanel中与标签和列表框 用户控件中的DataGridViewCell WPF
我需要把这个用户控件在DataGridCell从代码!不是来自XAML!谁知道如何做到这一点?
我有我的用户它由StackPanel中与标签和列表框 用户控件中的DataGridViewCell WPF
我需要把这个用户控件在DataGridCell从代码!不是来自XAML!谁知道如何做到这一点?
我通常做一个普通的网格,但我相信这应该翻译:
MyNameSpace.MyUserControl theUserControl = new MyNameSpace.MyUserControl();
theUserControl.Margin = new Thickness(0);
Grid.SetColumn(theUserControl, 1);
Grid.SetRow(theUserControl, 1);
myGridDisplay.Children.Add(theUserControl);
myGridDisplay是DataGrid视图? –
myGridDisplay是DataGrid的实例。 – 3264
DataGrid中没有儿童属性。你使用WPF中的DataGrid吗? –
那就是:
<DataGrid >
<DataGrid.Columns>
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
your stuff goes into here...
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
同样可以用代码来实现。
不是答案,但要注意将更多元素放入数据网格单元中。这是一个表演杀手。 – jrb
会有几人 –