Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 如何隐藏依赖项属性,使其无法在XAML上设置_Wpf_C# 4.0_Xamdatagrid - Fatal编程技术网

Wpf 如何隐藏依赖项属性,使其无法在XAML上设置

Wpf 如何隐藏依赖项属性,使其无法在XAML上设置,wpf,c#-4.0,xamdatagrid,Wpf,C# 4.0,Xamdatagrid,我试图自定义infragistics的xamdatagrid,我想实现一个特定于我的项目的功能,比如以特定的方式启用摘要,我想禁用设置摘要选项,该选项是XAML中的一个依赖项属性 我刚刚开始WPF,想看看这是否可行?我想在这里完成的就是隐藏现有的依赖属性,这样用户就不能通过XAML进行设置。您不能。您无法从XAML隐藏依赖项属性,除非您创建自己的依赖项属性,然后将其作为普通属性。既然您提到要自定义第三方的控件,那么就不必了。您可以使用EditorBrowsable属性从XAML中隐藏依赖项属性。

我试图自定义infragistics的xamdatagrid,我想实现一个特定于我的项目的功能,比如以特定的方式启用摘要,我想禁用设置摘要选项,该选项是XAML中的一个依赖项属性


我刚刚开始WPF,想看看这是否可行?我想在这里完成的就是隐藏现有的依赖属性,这样用户就不能通过XAML进行设置。

您不能。您无法从XAML隐藏依赖项属性,除非您创建自己的依赖项属性,然后将其作为普通属性。既然您提到要自定义第三方的控件,那么就不必了。

您可以使用EditorBrowsable属性从XAML中隐藏依赖项属性。请查看以下样本

 [EditorBrowsable(EditorBrowsableState.Never)]
    public int MyProperty
    {
        get { return (int)GetValue(MyPropertyProperty); }
        set { SetValue(MyPropertyProperty, value); }
    }

    // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty MyPropertyProperty =
        DependencyProperty.Register("MyProperty", typeof(int), typeof(MyControl), new PropertyMetadata(0));

此属性在System.ComponentModel命名空间下可用

从另一个答案来看,这似乎是不正确的。