Freezable.CloneCurrentValue Method


使用 Freezable 的当前值创建其可修改复本(深层副本)。Creates a modifiable clone (deep copy) of the Freezable using its current values.

 System::Windows::Freezable ^ CloneCurrentValue();
public System.Windows.Freezable CloneCurrentValue ();
member this.CloneCurrentValue : unit -> System.Windows.Freezable
Public Function CloneCurrentValue () 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 using its Freeze method. 现在,另一个线程可以访问 Freezable,并创建它可以访问的本地克隆。Now another thread can access the Freezable and make a local clone that it can access.

Notes to Inheritors

此方法使用 CloneCurrentValueCore(Freezable) 方法来生成克隆;重写 CloneCurrentValueCore(Freezable) Freezable 实施者必须确保在创建时未冻结副本。This method uses the CloneCurrentValueCore(Freezable) method to produce the clone; Freezable implementers who override CloneCurrentValueCore(Freezable) must ensure that the copy is not frozen on creation.

Applies to

See also