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

返回

冻结的副本FreezableA 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.

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.

继承者说明

此方法使用的虚拟GetAsFrozenCore(Freezable)方法以生成克隆。This method uses the virtual GetAsFrozenCore(Freezable) method to produce the clone.

适用于

另请参阅