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.

 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 ,然后使用方法将其冻结 FreezeUsing 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.

下表总结了和方法之间的 GetAsFrozen 差异 GetCurrentValueAsFrozenThe 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.