Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should not try to customize ButtonChrome. *Chrome classes are theme-specific, i.e. they contain implementation of a specific windows theme and you cannot override it. Look at the declaration of the "Microsoft_Windows_Themes" namespace in your resource dictionary - it probably contains something like PresentationFramework.Aero...</p> <p>What you should do in your custom templates is use usual Border instead of ButtonChrome and define triggers that will change its background, etc. when the button is pressed or hovered.</p> <p>Here is an example:</p> <pre><code>&lt;Style x:Key="BaseButtonStyle" TargetType="{x:Type ButtonBase}"&gt; &lt;Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}" /&gt; &lt;Setter Property="Background" Value="{StaticResource ButtonNormalBackground}" /&gt; &lt;Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}" /&gt; &lt;Setter Property="BorderThickness" Value="1" /&gt; &lt;Setter Property="Foreground" Value="{StaticResource ButtonNormalForeground}" /&gt; &lt;Setter Property="HorizontalContentAlignment" Value="Center" /&gt; &lt;Setter Property="VerticalContentAlignment" Value="Center" /&gt; &lt;Setter Property="Padding" Value="5,2,5,2" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type ButtonBase}"&gt; &lt;Border Name="Chrome" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="true" CornerRadius="2"&gt; &lt;ContentPresenter Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" /&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="True"&gt; &lt;Setter Property="Background" Value="{StaticResource ButtonHoverBackground}" /&gt; &lt;Setter Property="Foreground" Value="{StaticResource ButtonHoverForeground}" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsPressed" Value="True"&gt; &lt;Setter Property="Background" Value="{StaticResource ButtonPressedBackground}" /&gt; &lt;Setter Property="Foreground" Value="{StaticResource ButtonPressedForeground}" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="ToggleButton.IsChecked" Value="True"&gt; &lt;Setter Property="Background" Value="{StaticResource ButtonHoverBackground}" /&gt; &lt;Setter Property="Foreground" Value="{StaticResource ButtonNormalForeground}" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsEnabled" Value="false"&gt; &lt;Setter Property="Foreground" Value="#ADADAD" /&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; </code></pre> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload