I played around with brushes in VisualTree-Analyzer a bit to see how automatic freezing works. Here is the result of my tests:
All brushes that were attached via ControlTemplates, DataTemplates or styles were frozen, regardless of whether the Brush declaration was frozen in the template or in the style.
To do this, I checked the resulting visual tree of the following templates and styles:
<DataTemplate x:Key="Test_DataTemplate">
<Grid>
<Grid.Background>
<SolidColorBrush Color="Red"/>
</Grid.Background>
<TextBlock Text="{Binding}"/>
</Grid>
</DataTemplate>
<ControlTemplate x:Key="Test_ControlTemplate" TargetType="{x:Type ContentControl}">
<Border >
<Border.Background>
<SolidColorBrush Color="Green" />
</Border.Background>
<ContentPresenter />
</Border>
</ControlTemplate/>
<Style x:Key="Test_Style" TargetType="TextBlock">
<Setter Property="Background" >
<Setter.Value>
<SolidColorBrush Color="Yellow" />
</Setter.Value>
</Setter>
</Style>
<TextBlock >
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Background" >
<Setter.Value>
<SolidColorBrush Color="Violet" />
</Setter.Value>
</Setter>
</Style>
</TextBlock.Style>
</TextBlock>
, .
, , . , " " , WPF , Brush, . . .
, , "". . , . , . - , , .