Freezable.CloneCurrentValueCore(Freezable) 方法

定義

使用目前的屬性值,讓執行個體成為指定之 Freezable 的可修改複本 (深層複本)。Makes the instance a modifiable clone (deep copy) of the specified Freezable using current property values.

protected:
 virtual void CloneCurrentValueCore(System::Windows::Freezable ^ sourceFreezable);
protected virtual void CloneCurrentValueCore (System.Windows.Freezable sourceFreezable);
abstract member CloneCurrentValueCore : System.Windows.Freezable -> unit
override this.CloneCurrentValueCore : System.Windows.Freezable -> unit
Protected Overridable Sub CloneCurrentValueCore (sourceFreezable As Freezable)

參數

sourceFreezable
Freezable

要複製的 FreezableThe Freezable to be cloned.

備註

方法會呼叫這個方法 CloneCurrentValue ,不應該直接從程式碼呼叫這個方法,除非在覆寫這個方法時呼叫基底實作為。This method is called by the CloneCurrentValue method and should not be called directly from your code, except when calling the base implementation while overriding this method. 若要建立目前物件的可修改複本,請呼叫, CloneCurrentValue 而不是直接呼叫這個方法。To create a modifiable copy of the current object, call CloneCurrentValue instead of calling this method directly.

給繼承者的注意事項

如果您是衍生自 Freezable ,您可能需要覆寫這個方法。If you derive from Freezable, you may need to override this method. 覆寫的原因包括下列各項:Reasons to override include the following: -您的衍生類別具有未透過相依性屬性公開的資料。- Your derived class has data that is not exposed via dependency properties.

-您的衍生類別必須執行額外的初始化工作,而不是藉由直接覆寫來完成 CreateInstanceCore()- Your derived class must perform extra initialization work that cannot be accomplished by simply overriding CreateInstanceCore(). 例如,這適用于您的衍生類別所執行的 ISupportInitializeFor example, this applies if your derived class implements ISupportInitialize.

將所有資料儲存在相依性屬性中,而不需要執行額外初始初始化工作的類別,不需要覆寫 CloneCurrentValueCore(Freezable)Classes that store all their data in dependency properties and that do not need to perform extra initialization work do not need to override CloneCurrentValueCore(Freezable).

所有的執行都必須呼叫這個方法的基底實作為基礎。It is essential that all implementations call the base implementation of this method. 「執行」只應執行不是由預設實執行的工作。Implementations should only perform work that is not performed by the default implementation. 預設的執行會建立所有可寫入之本機設定屬性的深層複本。The default implementation makes deep copies of all writable, locally set properties. 如果物件包含運算式 (的相依性屬性,例如資料系結) ,則會複製運算式的目前值,但不會複製運算式本身。If the object contains dependency properties with expressions (such as a data binding), the current value of the expression is copied but not the expression itself.

如果物件具有動畫相依性屬性,則會複製這些屬性目前的動畫值,但不會複製動畫。If the object has animated dependency properties, the current animated value of those properties is copied, but the animations are not.

請注意,不會複製未設定的屬性,也不會有唯讀的屬性。Note that unset properties are not copied, nor are read-only properties. 如果這類屬性有凍結的預設值 Freezable ,該屬性值就會在其他可修改的複製品中保持凍結狀態。If such a property has a default value that is a frozen Freezable, that property value remains frozen in the otherwise modifiable clone.

下列清單摘要說明這個方法的預期行為。The following list summarizes the expected behavior for this method.

-所產生的複製包含所有 Freezable 子物件的複本。- The copy produced contains copies of all Freezable sub-objects.

-不會複製非設定和唯讀屬性。- Unset and read-only properties are not copied.

-如果是以動畫顯示內容,則會複製其目前的值,但是動畫本身則不會。- If a property is animated, its current value is copied, but the animation itself is not.

-建立時,這些子物件都未凍結。- None of these sub-objects are frozen on creation.

-複本本身不會凍結。- The copy itself is not frozen.

適用於

另請參閱