This documentation is archived and is not being maintained.

Freezable Class

Defines an object that has a modifiable state and a read-only (frozen) state. Classes that derive from Freezable provide detailed change notification, can be made immutable, and can clone themselves.

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

public abstract class Freezable extends DependencyObject
This class is abstract; see Inheritance Hierarchy for derived non-abstract classes usable in XAML.

The Freezable class provides special features that can help improve application performance when using objects that are expensive to modify or copy. Examples of Freezable objects include the following:

Deriving From Freezable

A class that derives from Freezable gains the following features:

  • Special states: a read-only (frozen) state and a writable state.

  • Thread safety: a frozen Freezable object can be shared across threads.

  • Detailed change notification: Unlike other DependencyObject objects, a Freezable object provides change notifications when sub-property values change.

  • Easy cloning: the Freezable class has already implemented several methods that produce deep clones.

For information on using and creating your own Freezable objects, see Freezable Objects Overview.

This example shows how to make a Freezable read-only by calling its Freeze method.

You cannot freeze a Freezable object if any one of the following conditions is true about the object:

  • It has animated or data bound properties.

  • It has properties that are set by a dynamic resource. For more information about dynamic resources, see the Resources Overview.

  • It contains Freezable sub-objects that cannot be frozen.

If these conditions are false for your Freezable object and you do not intend to modify it, consider freezing it to gain performance benefits.

The following example freezes a SolidColorBrush, which is a type of Freezable object.

Button myButton = new Button();
SolidColorBrush myBrush = new SolidColorBrush(Colors.Yellow);          

if (myBrush.CanFreeze)
    // Makes the brush unmodifiable.

myButton.Background = myBrush;  

For more information about Freezable objects, see the Freezable Objects Overview.

More Code

How to: Obtain a Writable Copy of a Read-Only Freezable This example shows how to use the Clone method to create a writable copy of a read-only Freezable.
How to: Determine Whether a Freezable Is Frozen This example shows how to determine whether a Freezable object is frozen. If you try to modify a frozen Freezable object, it throws an InvalidOperationException. To avoid throwing this exception, use the IsFrozen property of the Freezable object to determine whether it is frozen.


Any public static members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

When the IsFrozen property is false, a Freezable object can be accessed only from the thread on which it was created. Attempting to access it from another thread throws an InvalidOperationException. The Dispatcher.Invoke and Dispatcher.BeginInvoke methods provide support for marshalling to the correct thread.

When their IsFrozen property is true, Freezable objects are free-threaded. For more information, see Freezable Objects Overview.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0