如何在数据网格中添加列
我如何从代码后面添加 wpf 工具包数据网格中的列? 这不起作用:
DataGridTemplateColumn txtc = new DataGridTemplateColumn();
txtc.Header = "2";
myGrid.Columns.Add(txtc);
这是我的网格:
<Controls:DataGrid.CellStyle>
<Style TargetType="{x:Type Controls:DataGridCell}">
<Setter Property="Background">
<Setter.Value>
<MultiBinding Converter="{StaticResource myHighlighterConverter}">
<MultiBinding.Bindings>
<Binding RelativeSource="{RelativeSource Self}"></Binding>
<Binding Path="Row"></Binding>
</MultiBinding.Bindings>
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</Controls:DataGrid.CellStyle>
</Controls:DataGrid>
How i can add column in wpf toolkit datagrid from code behind?
this does not works:
DataGridTemplateColumn txtc = new DataGridTemplateColumn();
txtc.Header = "2";
myGrid.Columns.Add(txtc);
this is my grid :
<Controls:DataGrid.CellStyle>
<Style TargetType="{x:Type Controls:DataGridCell}">
<Setter Property="Background">
<Setter.Value>
<MultiBinding Converter="{StaticResource myHighlighterConverter}">
<MultiBinding.Bindings>
<Binding RelativeSource="{RelativeSource Self}"></Binding>
<Binding Path="Row"></Binding>
</MultiBinding.Bindings>
</MultiBinding>
</Setter.Value>
</Setter>
</Style>
</Controls:DataGrid.CellStyle>
</Controls:DataGrid>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WPF 4 有自己的 DataGrid,您创建的列来自该命名空间,它与 Toolkit-DataGrid 不兼容。如果您使用 WPF 4,您可能根本不应该使用 Toolkit DataGrid。
WPF 4 has its own DataGrid, the column you created is from that namespace, it is not compatible with the Toolkit-DataGrid. If you use WPF 4 you probably should not use the Toolkit DataGrid at all.