WPF中DataGrid列根据条件隐藏
2021-03-13 21:28
标签:header tap read val metadata key protected resource class 一、采用代理 二、使用Freezable public static readonly DependencyProperty DataProperty = DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null)); public object Data XAML引用BindingProxy Visibility绑定 WPF中DataGrid列根据条件隐藏 标签:header tap read val metadata key protected resource class 原文地址:https://www.cnblogs.com/vagrant-boy/p/12515913.html
1、xaml的Resources中添加一个FrameworkElement的代理
2、用一个隐藏的ContentControl绑定FrameworkElement代理
3、用代理做Visibility的数据源
BindingProxy类
public class BindingProxy:Freezable
{
protected override Freezable CreateInstanceCore()
{
return new BindingProxy();
//throw new NotImplementedException();
}
{
get { return (object)GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}
}
上一篇:winscp
文章标题:WPF中DataGrid列根据条件隐藏
文章链接:http://soscw.com/index.php/essay/64277.html