在设计器中看不到依赖项属性 [英] Don't see a dependency property in the Designer

查看:67
本文介绍了在设计器中看不到依赖项属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WPF MyUserControl.在内部,我定义了一个依赖项属性(默认情况下是Visual Studio)

I have a WPF MyUserControl. Inside, I defined a dependency property (as by default that does Visual Studio)

  Public Property Prop1 As String
    Get
      Return GetValue(Prop1Property).ToString()
    End Get

    Set(ByVal value As String)
      SetValue(Prop1Property, value)
    End Set
  End Property

  Public Shared ReadOnly Prop1Property As DependencyProperty = _
                      DependencyProperty.Register("Prop1", _
                      GetType(String), GetType(ctlMyUserControl.MyUserControl), _
                      New FrameworkPropertyMetadata(Nothing))

我成功地编译了该项目,但是在WPF的控件设计器中没有看到我的 Prop1 .为什么?

I successfully compiled the project, but I don't see in the WPF's control designer my Prop1. Why?

我还定义了一个常规"属性,例如

I also defined a "usual" property like

Public Property Test1 As String

但是我也不在设计器中看到它.为什么?

But I don't see it in the designer either. Why?

编辑

我在另一个WPF控件中添加了MyUserControl,在那里可以看到这些属性.但是在MyUserControl本身的设计器中(当我选择根UserControl时),该属性不可见...

I added MyUserControl in a other WPF control, and there I can see that properties. But in the designer of the MyUserControl itself (when I select the root UserControl), that properties are not visible...

推荐答案

我相信您必须修饰诸如

[Category("Configuration")]

[Category("Configuration"), Browsable(true), Description("Title to show")]

我认为在用户控件的设计器中看不到道具是一种正常的行为.您为什么要在那里看到它们,因为您只是在创建"用户控件而不使用它.

I think its a normal behavior to not see the props when you are in the designer of the userControl. Why would you want to see them there, as you are only "creating" the usercontrol, and not consuming it.

这篇关于在设计器中看不到依赖项属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆