Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Style:</p> <pre><code>&lt;Style TargetType="{x:Type Button}" x:Key="MyButton"&gt; &lt;Setter Property="OverridesDefaultStyle" Value="True" /&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="{x:Type Button}"&gt; &lt;Border x:Name="Border" CornerRadius="0" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" TextBlock.Foreground="{TemplateBinding Foreground}" BorderBrush="#FF404040"&gt; &lt;ContentPresenter Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True" /&gt; &lt;/Border&gt; &lt;ControlTemplate.Triggers&gt; &lt;Trigger Property="IsMouseOver" Value="true"&gt; &lt;Setter TargetName="Border" Property="Background" Value="White" /&gt; &lt;Setter TargetName="Border" Property="TextBlock.Foreground" Value="Blue" /&gt; &lt;/Trigger&gt; &lt;/ControlTemplate.Triggers&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; </code></pre> <p>Usage:</p> <pre><code>&lt;Button Width="100" Height="50" Content="Lalala" Style="{StaticResource MyButton}" Background="Brown" Foreground="Green" BorderThickness="2"&gt;&lt;/Button&gt; </code></pre> <ol> <li>You're missing the <code>ContentPresenter</code>, responsible for visualizing the <code>Content</code> property of the <code>Button</code>.</li> <li>To set the foreground you can use <code>TextBlock.Foreground</code> attached property.</li> <li><a href="http://msdn.microsoft.com/en-us/library/aa970773.aspx" rel="nofollow">Control Styles and Templates</a> has always been very usefull to me :)</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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