Freezable.CloneCurrentValueCore(Freezable) Method


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

 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)



要複製的 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.

Notes to Inheritors

如果您衍生自 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(). 例如,如果您的衍生類別會執行 ISupportInitialize,這就適用。For 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.

Applies to

See also