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.
Public MustInherit Class Freezable _ Inherits DependencyObject
Dim instance As Freezable
public abstract class Freezable : DependencyObject
public ref class Freezable abstract : public DependencyObject
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:
Brush
Pen
Geometry
Transform
AnimationTimeline
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. myBrush.Freeze(); } myButton.Background = myBrush;
For more information about Freezable objects, see the Freezable Objects Overview.
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