Freezable.GetAsFrozen Freezable.GetAsFrozen Freezable.GetAsFrozen 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.

public:
 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.

和方法可以改善複製效能, Freezable因為它們不會複製已凍結的子物件, 而只會以傳址方式複製它們。 GetCurrentValueAsFrozen GetAsFrozenThe 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.

給繼承者的注意事項

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

適用於

另請參閱