FrameworkPropertyMetadata.AffectsMeasure FrameworkPropertyMetadata.AffectsMeasure FrameworkPropertyMetadata.AffectsMeasure FrameworkPropertyMetadata.AffectsMeasure Property

定义

获取或设置一个值,该值表示依赖属性是否会影响布局引擎操作期间的测量过程。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

属性值

如果此元数据所在的依赖属性可能会影响测量过程,则为 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 , true其中, 为。Custom 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. 但是, 在对RegisterAddOwnerOverrideMetadata的调用中使用元数据后, 属性系统将密封传递元数据的详细信息的元数据实例和属性现在被视为不可变。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尝试设置此属性后, 将引发异常。 trueAttempting to set this property after IsSealed is true on this metadata instance will raise an exception.

XAML 文本用法XAML Text Usage

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

适用于

另请参阅