Freezable.GetCurrentValueAsFrozenCore(Freezable) 方法


將目前執行個體設為所指定 Freezable 的凍結複本。Makes the current instance a frozen clone of the specified Freezable. 如果物件具有動畫相依性屬性,則會複製其目前的動畫值。If the object has animated dependency properties, their current animated values are copied.

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



要複製和凍結的 FreezableThe Freezable to copy and freeze.


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

將所有資料儲存在相依性屬性中,而不需要執行額外初始初始化工作的類別,不需要覆寫 GetCurrentValueAsFrozenCore(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 GetCurrentValueAsFrozenCore(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. 預設的執行 Freezable 會使用方法建立新的 CreateInstance() ,並為其所包含的所有其他可寫入、本機設定的屬性建立深層複製的非凍結 freezable 和淺層複本。The default implementation creates a new Freezable using the CreateInstance() method and makes deep copies of unfrozen freezables and shallow copies of all other writable, locally set properties it contains. 如果物件具有資料系結的相依性屬性,則會複製資料系結,但可能無法再解析;如需複製資料系結物件的詳細資訊,請參閱可 凍結物件總覽If the object has data-bound dependency properties, the data bindings are copied but might no longer resolve; for more information about cloning data-bound objects, see Freezable Objects Overview. 如果物件具有動畫相依性屬性,則會複製這些屬性目前的動畫值,但不會複製動畫。If the object has animated dependency properties, the current animated value of those properties is copied, but the animations are not.

中的唯讀相依性屬性 Freezable 不會由此預設的執行複製。Read-only dependency properties within a Freezable are not copied by this default implementation.

如果您確實覆寫這個方法,您必須呼叫基底實作為。If you do override this method, you must call the base implementation.

複製時,您不需要 Freeze() 值。You do not need to Freeze() values as they are copied. 結果會在 GetAsFrozen() 傳回前凍結。The result is frozen by GetAsFrozen() before being returned.