Freezable.Clone Freezable.Clone Freezable.Clone Freezable.Clone Method

定義

建立這個 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.

備註

和方法會產生凍結Freezable物件的可修改複本 (方法也會Freezable複製未凍結的物件)。 CloneCurrentValue CloneThe 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

這個方法有助於線上程Freezable之間移動。This method can be useful for moving a Freezable between threads. 首先, 藉由Freezable呼叫其Freeze方法, 讓無法修改。First, make the Freezable unmodifiable by calling its Freeze method. 現在Freezable , 另一個執行緒可以存取, 並將Clone它設為可存取的本機。Now 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.

適用於

另請參閱