如何在 silverlight 的 Blend 属性浏览器中显示附加属性?
我创建了几个自定义控件,它们的子控件在 WPF 的属性浏览器中正确显示了附加属性,但在 silverlight 中,属性浏览器中没有出现任何附加属性。
如何在 silverlight 中添加对附加属性的设计时支持?
I created couple of custom controls and their childresn correctly shows the attached properties in Property Browser for WPF, but in silverlight none of the attached properties appear in Property Brower.
How to add design time support for attached properties in silverlight?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来可能需要使用一些属性来使自定义属性出现在设计器中:
http://blogs.msdn.com/jnak/archive/2008/01/17/showing-attached-properties-in-the-cider-wpf-designer.aspx
我还没有尝试过,不确定如果它可以与 Silverlight 一起使用。
Looks like there might be some attributes to work with to make custom properties appear in the designer:
http://blogs.msdn.com/jnak/archive/2008/01/17/showing-attached-properties-in-the-cider-wpf-designer.aspx
I have not tried it though, not sure if it will work with Silverlight.
Henrik 绝对适用于 VS2015/Blend 中的 WPF。仅供参考,我添加了链接文章中的一些信息,因为很多时候博客的链接会在几年后消失。
AttachedPropertyBrowsableForChildrenAttribute
此属性指示附加属性应对给定控件的子级可用。此属性有两种主要风格。一种包括后代,一种不包括后代。正如您可能期望的那样,包括后代是指包括控件的所有子代或简单的直接子代。
AttachedPropertyBrowsableForType
此属性允许您指定在设计器中选择给定类型或从该类型派生的类型时显示附加属性。以下示例将使您的附加属性在选择任何网格、派生网格、按钮或派生按钮时显示。
以下是 MSDN 文档链接:
https://msdn.microsoft.com/en-us/library/system.windows.attachedpropertybrowsableforchildrenattribute(v=vs.110).aspx
https://msdn.microsoft .com/en-us/library/system.windows.attachedpropertybrowsablefortypeattribute(v=vs.110).aspx
https://msdn.microsoft .com/en-us/library/system.windows.attachedpropertybrowsablewhenattributepresentattribute(v=vs.110).aspx
Henrik's definitely works for WPF in VS2015/Blend. Just for reference, I'm adding some of the info from the linked article because so many times links to blogs die after a number of years.
AttachedPropertyBrowsableForChildrenAttribute
This attribute indicates that the attached property should be available for the children of the given control. There are two main flavors for this attribute. One that includes descendants and one that does not. As you might expect including descendants refers to including all children or simply the direct children of the control.
AttachedPropertyBrowsableForType
This attribute allows you to specify that your attached property show up when a given type or types derived from that type are selected in the designer. The following sample would make your attached property show up when any Grid, derived Grid, Button or derived Button is selected.
And here are the MSDN doc links:
https://msdn.microsoft.com/en-us/library/system.windows.attachedpropertybrowsableforchildrenattribute(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.windows.attachedpropertybrowsablefortypeattribute(v=vs.110).aspx
https://msdn.microsoft.com/en-us/library/system.windows.attachedpropertybrowsablewhenattributepresentattribute(v=vs.110).aspx