This documentation is archived and is not being maintained.
How to: Make a Freezable Read-Only
This example shows how to make a
read-only by calling its Freezable method. Freeze
You cannot freeze a
object if any one of the following conditions is Freezable about the object: true
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
sub-objects that cannot be frozen. Freezable
If these conditions are
for your false object and you do not intend to modify it, consider freezing it to gain performance benefits. Freezable
The following example freezes a
, which is a type of SolidColorBrush object. Freezable
Button myButton = new Button();
SolidColorBrush myBrush = new SolidColorBrush(Colors.Yellow);
// Makes the brush unmodifiable.
myButton.Background = myBrush;
For more information about
objects, see the Freezable . Freezable Objects Overview Reference Concepts Other Resources