Freezable.Clone 方法

定义

创建 Freezable 的可修改克隆,以制作该对象值的深层副本。Creates a modifiable clone of the Freezable, making deep copies of the object's values. 在复制此对象的依赖属性时,此方法会复制表达式(可能不再解析),但不复制动画或其当前值。When copying the object's dependency properties, this method copies expressions (which might no longer resolve) but not animations or their current values.

public:
 System::Windows::Freezable ^ Clone();
public System.Windows.Freezable Clone ();
member this.Clone : unit -> System.Windows.Freezable
Public Function Clone () As Freezable

返回

当前对象的可修改复本。A modifiable clone of the current object. 即使源的 IsFrozen 属性为 true.,所克隆对象的 IsFrozen 属性也为 falseThe cloned object's IsFrozen property is false even if the source's IsFrozen property is true.

注解

CloneCloneCurrentValue 方法将生成冻结的 Freezable 对象的可修改克隆(这些方法还会克隆未冻结的 Freezable 对象)。The Clone and CloneCurrentValue methods produce modifiable clones of frozen Freezable objects (the methods also clone Freezable objects that are not frozen). 克隆实际上是当前对象的深层副本。The clone is effectively a deep copy of the current object.

下表总结了 CloneCloneCurrentValue 方法之间的差异。The following table summarizes the differences between the Clone and CloneCurrentValue methods.

操作Action 克隆方法行为Clone method behavior CloneCurrentValue 方法行为CloneCurrentValue method behavior
复制具有表达式的依赖项属性Copying a dependency property that has an expression 表达式已复制,但可能不再解析。The expression is copied, but might no longer resolve. 有关详细信息,请参阅 Freezable 对象概述For more information, see Freezable Objects Overview. 复制表达式的当前值,而不是表达式本身。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. 如果未设置的属性具有默认值,该默认值为已冻结 Freezable,则该属性值在其他可修改复本中保持为冻结状态。If an unset property has a default value that is a frozen Freezable, that property value remains frozen in the otherwise modifiable clone.

在线程之间移动一个冻结Move a Freezable Between Threads

此方法可用于在线程之间移动 FreezableThis method can be useful for moving a Freezable between threads. 首先,通过调用其 Freeze 方法使 Freezable 成为不可修改的。First, make the Freezable unmodifiable by calling its Freeze method. 现在,另一个线程可以访问 Freezable,并使其可以访问的本地 CloneNow another thread can access the Freezable and make a local Clone that it can access.

继承者说明

此方法使用 CloneCore(Freezable) 来生成克隆。This method uses CloneCore(Freezable) to produce the clone. 若要修改派生类中此方法的行为,请重写 CloneCore(Freezable) 方法。To modify the behavior of this method in a derived class, override the CloneCore(Freezable) method.

适用于

另请参阅