Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>How is this</p> <pre><code>BasedOn="{StaticResouce DefaultButton}" </code></pre> <p>supposed to refer to the default button style? This crashes because DefaultButton is an undefined resource in your app.</p> <p>It should be:</p> <pre><code>BasedOn="{StaticResource {x:Type Button}}" </code></pre> <p>EDIT: Sorry, answered too hastily.</p> <p>I noticed now your button has a Style={} set, and is pointing to a style called OkBUttonStyle. This is the style that should define everything and be based on the default button style. By everything, I include those triggers. What you are saying in the XAML is that Style is the Content of your Button. </p> <p>Maybe some code will help:</p> <pre><code> &lt;Window x:Class="WindowsApplication7.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="WindowsApplication7" Height="300" Width="300" &gt; &lt;Window.Resources&gt; &lt;Style TargetType="{x:Type Button}" x:Key="defaultButtonStyle"&gt; &lt;Setter Property="Background" Value="Red" /&gt; &lt;/Style&gt; &lt;Style TargetType="{x:Type Button}" x:Key="okButtonStyle" BasedOn="{StaticResource defaultButtonStyle}"&gt; &lt;Setter Property="Foreground" Value="Green" /&gt; &lt;Style.Triggers&gt; &lt;Trigger Property="IsEnabled" Value="True"&gt; &lt;Setter Property="Background" Value="Yellow" /&gt; &lt;/Trigger&gt; &lt;Trigger Property="IsEnabled" Value="False"&gt; &lt;Setter Property="Foreground" Value="Blue" /&gt; &lt;/Trigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/Window.Resources&gt; &lt;StackPanel&gt; &lt;Button&gt;System default&lt;/Button&gt; &lt;Button Style="{StaticResource defaultButtonStyle}"&gt;My Default&lt;/Button&gt; &lt;Button Style="{StaticResource okButtonStyle}"&gt;Ok&lt;/Button&gt; &lt;Button Style="{StaticResource okButtonStyle}" IsEnabled="False"&gt;Ok disabled&lt;/Button&gt; &lt;/StackPanel&gt; &lt;/Window&gt; </code></pre>
 

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