【问题标题】:Dependency Property Not showing in Property Pane依赖属性未显示在属性窗格中
【发布时间】:2018-07-29 07:23:09
【问题描述】:

我像这样将一个属性附加到 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 中选择控件时,未显示该属性。如何让属性显示在属性窗格中?

【问题讨论】:

  • 它也不显示任何普通属性,例如背景或可见性。也许您必须从​​ Windows 窗体的代码隐藏中设置它们的值?
  • 我猜这不是完美的解决方案,但是是的,智能感知在 CodeBehind 中显示了该属性。所以我只是把它放在那里。谢谢!

标签: c# wpf winforms xaml


【解决方案1】:

您可以从代码隐藏中设置属性的值。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多