Freezable.GetCurrentValueAsFrozen Freezable.GetCurrentValueAsFrozen Freezable.GetCurrentValueAsFrozen Freezable.GetCurrentValueAsFrozen Method


使用目前屬性值,建立 Freezable 的凍結複本。Creates a frozen copy of the Freezable using current property values. 因為複本已凍結,所以會以傳址方式複製任何凍結子物件。Because the copy is frozen, any frozen sub-objects are copied by reference.

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


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


使用此方法類似于使用CloneCurrentValue建立複本, 然後使用Freeze方法加以凍結。Using this method is similar to creating a copy using the CloneCurrentValue 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複本, 請CloneCurrentValue使用方法。To create a copy of the Freezable that is not frozen, use the CloneCurrentValue method.


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