如何将 PropertyChangedCallback 添加到基类的依赖属性?
我有一个从 System.Windows.Controls.UserControl 派生的类,我需要将 PropertyChangedCallback 添加到 FrameworkElement.Margin 依赖属性。
这是如何通过我的 C# 代码实现的?我在 MSDN 中找不到任何好的例子。
I have a class derived from System.Windows.Controls.UserControl, and I need to add a PropertyChangedCallback to the FrameworkElement.Margin dependency-property.
How is this accomplished from my C# code? I can't find any good examples of this in MSDN.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过调用 OverrideMetadata 来执行此操作你的用户控件。
这提供了合并 PropertyChangedCallback 特征的方法。有关详细信息,请参阅 MSDN 页面的 依赖属性元数据 (搜索标题为“覆盖元数据”的部分)。
You can do this via calling OverrideMetadata in your UserControl.
This provides the means to merge PropertyChangedCallback characteristics. For details, see the MSDN page for Dependency Property Metadata (search for the section titled "Overriding Metadata").