WPF datagrid动态影藏列

public class BindingProxy : Freezable
    {
        #region Overrides of Freezable

        protected override Freezable CreateInstanceCore()
        {
            return new BindingProxy();
        }

        #endregion

        public object Data
        {
            get { return (object)GetValue(DataProperty); }
            set { SetValue(DataProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Data.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty DataProperty =
            DependencyProperty.Register("Data", typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
    }

前台绑定
<Window.Resources>
<local1:BindingProxy x:Key="proxy" Data="{Binding}"/>
</Window.Resources>

绑定静态资源 其中Vis为viewmodel中的属性

posted @ 2023-06-13 13:41  Hey,Coder!  阅读(100)  评论(0编辑  收藏  举报