FrameworkPropertyMetadata.AffectsMeasure 属性

定义

获取或设置一个值,该值表示依赖属性是否会影响布局引擎操作期间的测量过程。Gets or sets a value that indicates whether a dependency property potentially affects the measure pass during layout engine operations.

public:
 property bool AffectsMeasure { bool get(); void set(bool value); };
public bool AffectsMeasure { get; set; }
member this.AffectsMeasure : bool with get, set
Public Property AffectsMeasure As Boolean

属性值

Boolean

如果此元数据所在的依赖属性可能会影响测量过程,则为 true;否则为 falsetrue if the dependency property on which this metadata exists potentially affects the measure pass; otherwise, false. 默认为 falseThe default is false.

例外

已对依赖属性操作应用了元数据,因此元数据已密封,且无法设置其属性。The metadata has already been applied to a dependency property operation, so that metadata is sealed and properties of the metadata cannot be set.

示例

下面的示例从各种依赖属性字段获取默认元数据,查询 FrameworkPropertyMetadata 其上各种属性的值,并使用该信息来填充表以实现 "元数据浏览器"。The following example obtains the default metadata from various dependency property fields, queries the value of various FrameworkPropertyMetadata properties on it, and uses the information to populate a table to implement a "metadata browser".

pm = dp.GetMetadata(dp.OwnerType);
pm = dp.GetMetadata(dp.OwnerType)
FrameworkPropertyMetadata fpm = pm as FrameworkPropertyMetadata;
if (fpm!=null) {
    AffectsArrange.Text = (fpm.AffectsArrange) ? "Yes" : "No";
    AffectsMeasure.Text = (fpm.AffectsMeasure) ? "Yes" : "No";
    AffectsRender.Text = (fpm.AffectsRender) ? "Yes" : "No";
    Inherits.Text = (fpm.Inherits) ? "Yes" : "No";
    IsDataBindingAllowed.Text = (fpm.IsDataBindingAllowed) ? "Yes" : "No";
    BindsTwoWayByDefault.Text = (fpm.BindsTwoWayByDefault) ? "Yes" : "No";
}         
Dim fpm As FrameworkPropertyMetadata = TryCast(pm, FrameworkPropertyMetadata)
If fpm IsNot Nothing Then
    AffectsArrange.Text = If((fpm.AffectsArrange), "Yes", "No")
    AffectsMeasure.Text = If((fpm.AffectsMeasure), "Yes", "No")
    AffectsRender.Text = If((fpm.AffectsRender), "Yes", "No")
        [Inherits].Text = If((fpm.Inherits), "Yes", "No")
    IsDataBindingAllowed.Text = If((fpm.IsDataBindingAllowed), "Yes", "No")
    BindsTwoWayByDefault.Text = If((fpm.BindsTwoWayByDefault), "Yes", "No")

注解

FrameworkElementFrameworkContentElement 包括的实现 OnPropertyChanged ,该实现监视某个元素上存在的所有依赖项属性的有效值更改。FrameworkElement and FrameworkContentElement include an implementation of OnPropertyChanged that monitors effective value changes to all dependency properties that exist on an element. 作为该逻辑的一部分,更改有效值并且具有设置为的元数据的依赖项属性 AffectsMeasure true 将启动延迟请求,以使该元素的视觉对象无效。As part of that logic, dependency properties that change effective value and have metadata with AffectsMeasure set to true will initiate a deferred request to invalidate the visuals for that element. 由于已存在此 WPF 框架级别的实现,因此通常无需查找依赖属性,除非确实要 AffectsMeasure 替换或修改 WPF 框架级别的布局行为。Because this WPF framework-level implementation is already in place, you typically do not need to look for dependency properties with AffectsMeasure unless you are substantially replacing or modifying the WPF framework-level layout behavior.

自定义 OnPropertyChanged 实现可能会为依赖项属性更改选择类似行为,其中 AffectsMeasure ,为 trueCustom OnPropertyChanged implementations might choose to have similar behavior for dependency property changes where AffectsMeasure is true.

派生类上的属性 PropertyMetadata 通常在对象模型中定义为可读写。Properties on derived classes of PropertyMetadata are typically defined in the object model as read-write. 这样就可以在实例初始化后进行调整。This is so they can be adjusted after initialization of the instance. 但是,在对、或的调用中使用元数据后 RegisterAddOwner OverrideMetadata 属性系统将密封传递元数据的详细信息的元数据实例和属性现在被视为不可变。However, after the metadata is consumed as part of a call to Register, AddOwner, or OverrideMetadata, the property system will seal that metadata instance and properties that convey the specifics of the metadata are now considered immutable. IsSealed true 在此元数据实例上尝试设置此属性后,将引发异常。Attempting to set this property after IsSealed is true on this metadata instance will raise an exception.

XAML 文本用法XAML Text Usage

此类的成员通常不在中使用 XAMLXAMLMembers of this class are not typically used in XAMLXAML.

适用于

另请参阅