最佳答案
如何通过绑定隐藏 WPF DataGrid
中的列?
我就是这么做的:
<DataGridTextColumn Header="Column header"
Binding="{Binding ColumnValue}"
Width="100"
ElementStyle="{StaticResource DataGridRightAlign}"
Visibility="{Binding MyColumnVisibility}" />
这就是我得到的(除了仍然可见的柱子之外) :
系统。窗户。数据错误: 2: 找不到控制目标元素的 FrameworkElement 或 FrameworkContentElement。BindingExpression: Path = MyColumnVisiability; Dataltem = null; target 元素是“ DataGridTextColumn”(HashCode = 1460142) ; target 属性是“ Visiability”(类型为“ Visiability”)
如何修复绑定?