Freezable.GetAsFrozen Method


使用基底 (非動畫) 屬性值,建立 Freezable 的凍結複本。Creates a frozen copy of the Freezable, using base (non-animated) property values. 因為複本已凍結,所以會以傳址方式複製任何凍結子物件。Because the copy is frozen, any frozen sub-objects are copied by reference.

 System::Windows::Freezable ^ GetAsFrozen();
public System.Windows.Freezable GetAsFrozen ();
member this.GetAsFrozen : unit -> System.Windows.Freezable
Public Function GetAsFrozen () As Freezable



Freezable 的凍結複本。A frozen copy of the Freezable. 複本的 IsFrozen 屬性是設定為 trueThe copy's IsFrozen property is set to true.


Freezable 包含運算式或動畫屬性,因此無法予以凍結。The Freezable cannot be frozen because it contains expressions or animated properties.


在呼叫這個方法之前,您應該先檢查 CanFreeze 屬性,以確認 Freezable 可以凍結。You should check the CanFreeze property before calling this method to verify that the Freezable can be frozen. 使用此方法類似于使用 Clone 建立複本,然後使用 Freeze 方法加以凍結。Using this method is similar to creating a copy using the Clone and then freezing it with the Freeze method.

GetAsFrozenGetCurrentValueAsFrozen 方法可以改善複製效能,因為它們不會複製已凍結的 Freezable 子物件。它們只會以傳址方式複製它們。The GetAsFrozen and GetCurrentValueAsFrozen methods can improve copying performance because they do not clone Freezable sub-objects that are already frozen; they only copy them by reference.

下表摘要說明 GetAsFrozenGetCurrentValueAsFrozen 方法之間的差異。The following table summarizes the differences between the GetAsFrozen and GetCurrentValueAsFrozen methods.

動作Action GetAsFrozen 方法行為GetAsFrozen method behavior GetCurrentValueAsFrozen 方法行為GetCurrentValueAsFrozen method behavior
複製具有運算式的相依性屬性Copying a dependency property that has an expression 方法會擲回 InvalidOperationException,因為它無法 Freeze 屬性。The method throws an InvalidOperationException because it cannot Freeze the property. 運算式的目前值已複製,而不是運算式本身。The current value of the expression is copied, but not the expression itself.
複製動畫相依性屬性Copying an animated dependency property 會複製屬性的基底(非動畫)值。The property's base (non-animated) value is copied. 不會複製動畫。Animations are not copied. 會複製屬性目前的動畫值。The property's current animated value is copied. 不會複製動畫。Animations are not copied.

請注意,不會複製未設定的屬性,也不會有唯讀屬性。Note that unset properties are not copied, nor are read-only properties.

若要建立未凍結的 Freezable 複本,請使用 Clone 方法。To create a copy of the Freezable that is not frozen, use the Clone method.

Notes to Inheritors

這個方法會使用虛擬 GetAsFrozenCore(Freezable) 方法來產生複製。This method uses the virtual GetAsFrozenCore(Freezable) method to produce the clone.

Applies to

See also