#143 – Dependency Property Value Sources: #9 – Theme Style

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).


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #143 – Dependency Property Value Sources: #9 – Theme Style

  1. Pingback: #133 – Where a Dependency Property Gets Its Value « 2,000 Things You Should Know About WPF

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: