Freezable.GetCurrentValueAsFrozen 方法

定義

使用目前屬性值,建立 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.

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

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 複本,請使用 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.

適用於

另請參閱