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.

适用于

另请参阅