How can WPF objects deriving from Freezable be frozen in XAML?

前端 未结 2 1775
南方客
南方客 2020-12-08 04:29

Many types in WPF derive from Freezable. It provides immutability to mutable POCO objects and allows for improved performance in certain situations.

So

2条回答
  •  无人及你
    2020-12-08 04:59

    To freeze a Freezable object declared in markup, you use the Freeze attribute defined in XML namespace http://schemas.microsoft.com/winfx/2006/xaml/presentation/options.

    In the following example, a SolidColorBrush is declared as a page resource and frozen. It is then used to set the background of a button.

    
    
      
        
        
      
    
      
      
    
    
    

    Source: Freezable Objects Overview

提交回复
热议问题