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. 嘗試在這個中繼資料實例IsSealedtrue設定這個屬性之後, 就會引發例外狀況。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.

適用於

另請參閱