FrameworkPropertyMetadata.AffectsMeasure Property

Definition

取得或設定值,指出相依性屬性在配置引擎作業期間,是否可能會影響測量行程。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

Property Value

Boolean

如果這個中繼資料所在的相依性屬性可能會影響測量行程,則為 true;否則為 falsetrue if the dependency property on which this metadata exists potentially affects the measure pass; otherwise, false. 預設值為 falseThe default is false.

Exceptions

中繼資料已套用至相依性屬性作業,因此中繼資料已密封,而且無法設定中繼資料的屬性。The metadata has already been applied to a dependency property operation, so that metadata is sealed and properties of the metadata cannot be set.

Examples

下列範例會從各種相依性屬性欄位中取得預設的中繼資料,查詢其上各種 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")

Remarks

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 執行可能會選擇對 trueAffectsMeasure 的相依性屬性變更具有類似的行為。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. 嘗試在這個中繼資料實例上 true IsSealed 之後設定這個屬性,將會引發例外狀況。Attempting 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.

Applies to

See also