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 属性,以验证是否可以冻结 FreezableYou 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