gpt4 book ai didi

wpf - WPF中的PropertyMetaData、UIPropertyMetadata、FrameworkMetaData有什么区别

转载 作者:行者123 更新时间:2023-12-04 01:47:11 25 4
gpt4 key购买 nike

我知道这些类之间的基本区别,当我们备份属性时使用 PropertyMetadata,当我们想要支持动画时使用 UIPropertyMetadata,以及用于用户控件中使用的框架属性的 FrameworkMetadata。

但我只了解理论部分。
如果你能解释一个最简单的例子,在 3 个不同的依赖属性中使用所有这 3 个类来清楚地区分它们,那将是一个很好的例子。

提前致谢。

最佳答案

来源:PropertyMetadata vs. FrameworkPropertyMetadata

When you implement a custom dependency property and you register the property by calling DependencyProperty.Register, you specify some metadata for the property by passing it an instance of PropertyMetadata. This can be an instance of the PropertyMetadata class or an instance of one of its subclasses. The differences are shown below.

PropertyMetadata – Basic metadata relating to dependency properties

  • CoerceValueCallback – coerce the value when being set
  • DefaultValue – a default value for the property
  • PropertyChangedCallback – respond to new effective value for the property

UIPropertyMetadata – derives from PropertyMetadata and adds:

  • IsAnimationProhibited – disable animations for this property?

FrameworkPropertyMetadata – derives from UIPropertyMetadata and adds:

  • AffectsArrange, AffectsMeasure, AffectsParentArrange, AffectsParentMeasure, AffectsRender – Should layout calculations be re-run after property value changes?
  • BindsTwoWayByDefault, DefaultUpdateSourceTrigger, IsDataBindingAllowed, IsNotDataBindable – Dictates how property participates in data binding
  • Inherits, OverridesInheritanceBehavior – Does inheritance work for this property?
  • Journal – Store this value when journaling?
  • SubPropertiesDoNotAffectRender – Check properties of this object when layout changes?

关于wpf - WPF中的PropertyMetaData、UIPropertyMetadata、FrameworkMetaData有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14221636/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com