#143 – Dependency Property Value Sources: #9 – Theme Style
December 2, 2010 1 Comment
The ninth source in the list of sources for the base value of a dependency property is a theme style. A property gets its base value from a theme style if the value comes from a setter in the default style for a control. Every control that ships with WPF has a default style that dictates its appearance, also known as a theme style.
If we look at the default style for a ComboBox control, we see that the default style sets the Background property of the ComboBox:
<Style x:Key="ComboBoxStyle1" TargetType="{x:Type ComboBox}"> <Setter Property="FocusVisualStyle" Value="{StaticResource ComboBoxFocusVisual}"/> <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/> <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
So, by default, the source of this property is DefaultStyle (theme style).
If we then set the IsEditable property to true, a trigger in the default style fires and the source becomes DefaultStyleTrigger (theme style trigger).