Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Freezable.GetAsFrozen Method ()


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Creates a frozen copy of the Freezable, using base (non-animated) property values. Because the copy is frozen, any frozen sub-objects are copied by reference.

Namespace:   System.Windows
Assembly:  WindowsBase (in WindowsBase.dll)

public Freezable GetAsFrozen()

Return Value

Type: System.Windows.Freezable

A frozen copy of the Freezable. The copy's IsFrozen property is set to true.

Exception Condition

The Freezable cannot be frozen because it contains expressions or animated properties.

You should check the CanFreeze property before calling this method to verify that the Freezable can be frozen. Using this method is similar to creating a copy using the Clone and then freezing it with the Freeze method.

The GetAsFrozen and GetCurrentValueAsFrozen methods can improve copying performance because they do not clone Freezable sub-objects that are already frozen; they only copy them by reference.

The following table summarizes the differences between the GetAsFrozen and GetCurrentValueAsFrozen methods.


GetAsFrozen method behavior

GetCurrentValueAsFrozen method behavior

Copying a dependency property that has an expression

The method throws an InvalidOperationException because it cannot Freeze the property.

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, nor are read-only properties.

To create a copy of the Freezable that is not frozen, use the Clone method.

Notes to Inheritors:

This method uses the virtual GetAsFrozenCore method to produce the clone.

.NET Framework
Available since 3.0
Return to top
© 2018 Microsoft