如何将 PropertyChangedCallback 添加到基类的依赖属性?

发布于 2024-08-02 20:44:01 字数 162 浏览 1 评论 0原文

我有一个从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

高冷爸爸 2024-08-09 20:44:01

您可以通过调用 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").

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文