【发布时间】:2020-10-14 03:56:49
【问题描述】:
我正在尝试使用代码在 WPF 中绑定 DataGridTextColumn 的可见性属性。具体来说,我需要将它绑定到框架元素的数据上下文。
<FrameworkElement x:Name="DataContextControl"/>
在 Xaml 中,我会这样做:
<DataGridTextColumn Visibility="{Binding DataContext, Source = {x:Reference DataContextControl}}">
我正在动态构建列,所以这里不是一个选项。由于 DataGridTextColumn 没有 setbinding 命令,如何以编程方式进行相同的绑定?
我尝试使用 SetValue 无济于事。
【问题讨论】:
-
这里有什么有用的吗? stackoverflow.com/questions/916454/…
-
不,那是指列上的绑定属性,但我需要能够绑定到可见性属性。不过谢谢!
标签: c# wpf xaml data-binding