从属属性未显示在属性窗格中

时间:2018-07-29 07:23:10

标签: c# wpf winforms xaml

我将属性附加到WPF用户控件,如下所示:

public partial class Datensatzliste : UserControl
{
    public int Modulnummer
    {
        get { return (int)this.GetValue(ModulnummerProperty); }
        set { this.SetValue(ModulnummerProperty, value); }
    }

    public static DependencyProperty ModulnummerProperty = DependencyProperty.Register("Modulnummer", typeof(int), typeof(Datensatzliste), new PropertyMetadata(0));
    ....
}

该控件托管在WinForms应用程序中。当我在Visual Studio中选择“控件”时,不显示该属性。我应该如何将该属性显示在属性窗格中?

enter image description here

1 个答案:

答案 0 :(得分:0)

您可以从后面的代码中设置属性的值。