FrameworkPropertyMetadata.AffectsRender FrameworkPropertyMetadata.AffectsRender FrameworkPropertyMetadata.AffectsRender FrameworkPropertyMetadata.AffectsRender Property

定义

获取或设置一个值,该值指示依赖属性是否会以某种方式(这种方式不会具体影响排列或测量,但将请求重绘)对常规布局造成潜在影响。Gets or sets a value that indicates whether a dependency property potentially affects the general layout in some way that does not specifically influence arrangement or measurement, but would require a redraw.

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

属性值

如果该元数据所在的依赖属性会影响呈现,则为true ;否则为 falsetrue if the dependency property on which this metadata exists affects rendering; 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. 作为该逻辑的一部分, 更改有效值并且具有AffectsRender设置为true的元数据的依赖项属性将启动延迟请求, 以使该元素的视觉对象无效。As part of that logic, dependency properties that change effective value and have metadata with AffectsRender set to true will initiate a deferred request to invalidate the visuals for that element. 由于已存在此 WPF 框架级别的实现, 因此通常无需查找依赖属性AffectsRender , 除非确实要替换或修改 WPF 框架级别的布局行为。Because this WPF framework-level implementation is already in place, you typically do not need to look for dependency properties with AffectsRender unless you are substantially replacing or modifying the WPF framework-level layout behavior.

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

的任何派生类的PropertyMetadata属性通常在对象模型中定义为可读写。Properties on any 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.

适用于

另请参阅