FrameworkPropertyMetadata.AffectsParentArrange 属性

定义

获取或设置一个值,该值表示依赖属性是否会影响布局引擎操作期间父元素布局的排列处理过程。Gets or sets a value that indicates whether a dependency property potentially affects the arrange pass of its parent element's layout during layout engine operations.

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

属性值

如果此元数据所在的依赖属性可能会特别影响其父元素上的排列处理过程,则为 true;否则为 falsetrue if the dependency property on which this metadata exists potentially affects the arrange pass specifically on its parent element; 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.

注解

FrameworkElementFrameworkContentElement包括的OnPropertyChanged实现, 该实现监视某个元素上存在的所有依赖项属性的有效值更改。FrameworkElement and FrameworkContentElement include an implementation of OnPropertyChanged that monitors effective value changes to all dependency properties that exist on an element. 作为该逻辑的一部分, 更改有效值并且具有AffectsParentArrange设置为true的元数据的依赖项属性将启动延迟请求来使父元素的视觉对象无效。As part of that logic, dependency properties that change effective value and have metadata with AffectsParentArrange set to true will initiate a deferred request to invalidate the visuals for the parent element.

通常, FrameworkElement您不需要使用AffectsParentArrange将属性的更改报告给父元素, 因为元素本身true已经有了自己AffectsArrange的。Generally, you do not need to report changes of a FrameworkElement property to a parent element using AffectsParentArrange because the element itself would already have its own AffectsArrange as true. 这通常是足够的, 因为在适当的情况下, 子元素中的更改通常会启动父排列。That is usually sufficient, because changes in the child element generally initiate a parent arrange when appropriate. AffectsParentArrange有时用于FrameworkContentElement派生类。AffectsParentArrange is sometimes used for a FrameworkContentElement derived class. 在这种情况下, 子元素设置属性, 但FrameworkContentElement派生类不控制其自身的呈现。In this case, the child element sets a property, but a FrameworkContentElement derived class does not control its own rendering. 呈现由FrameworkElement充当内容宿主的父元素处理。The rendering is handled by a FrameworkElement parent element that serves as the content host. 例如, 子元素对FixedPage.Left附加属性值的更改会使父元素的排列失效, 因为父元素在父级中的位置必须更改。For instance, a change to the value of the FixedPage.Left attached property by a child element invalidates arrange of the parent, because the position of the child in the parent must be changed. 因此, FixedPage.Left附加属性的AffectsParentArrange元数据的数据true为。Therefore, the FixedPage.Left attached property has metadata where AffectsParentArrange is true. 另一个示例Padding是; 当此属性发生更改时, 父级可能会根据可用空间更改子项的位置。Another example is Padding; when this property changes, the parent might change the positioning of the child, depending on available space.

由于已存在此 WPF 框架级别的实现, 因此通常无需查找依赖属性AffectsParentArrange , 除非确实要替换或修改 WPF 框架级别的布局行为。Because this WPF framework-level implementation is already in place, you typically do not need to look for dependency properties with AffectsParentArrange unless you are substantially replacing or modifying the WPF framework-level layout behavior.

OnPropertyChanged定义实现可能会为依赖项属性更改选择类似行为AffectsParentArrange , true其中, 为。Custom OnPropertyChanged implementations might choose to have similar behavior for dependency property changes where AffectsParentArrange 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.

适用于

另请参阅