Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-make-a-freezable-read-only.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07:00

1.9 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
How to: Make a Freezable Read-Only 03/30/2017
csharp
vb
Freezable objects [WPF], making read-only
6c544b7d-d3c9-4736-aa90-4b8728234ccb

How to: Make a Freezable Read-Only

This example shows how to make a xref:System.Windows.Freezable read-only by calling its xref:System.Windows.Freezable.Freeze%2A method.

You cannot freeze a xref:System.Windows.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 XAML Resources.

  • It contains xref:System.Windows.Freezable sub-objects that cannot be frozen.

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

Example

The following example freezes a xref:System.Windows.Media.SolidColorBrush, which is a type of xref:System.Windows.Freezable object.

[!code-csharpfreezablesample_procedural#FreezeExample1] [!code-vbfreezablesample_procedural#FreezeExample1]

For more information about xref:System.Windows.Freezable objects, see the Freezable Objects Overview.

See also