Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Create a resource dictionary (Add New Item -> Resource Dictionary), then make a style and template for your buttons as so:</p> <pre><code>&lt;ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; &lt;Style x:Key="ButtonStyle" TargetType="Button"&gt; &lt;Setter Property="Height" Value="120" /&gt; &lt;Setter Property="Width" Value="250" /&gt; &lt;Setter Property="RenderTransform"&gt; &lt;Setter.Value&gt; &lt;RotateTransform x:Name="btnTransform" Angle="0" /&gt; &lt;/Setter.Value&gt; &lt;Setter Property="Template"&gt; &lt;Setter.Value&gt; &lt;ControlTemplate TargetType="Button"&gt; &lt;Border BorderThickness="2" BorderBrush="Black" Background="Red"&gt; &lt;Grid VerticalAlignment="Top" HorizontalAlignment="Left" Height="120" Width="250"&gt; &lt;Image Grid.ColumnSpan="2" Grid.RowSpan="2" Height="120" VerticalAlignment="Center" HorizontalAlignment="Center" Stretch="Fill" Width="120" Source="/SystemPowerShortcuts;component/image_res/shutdown.png" /&gt; &lt;TextBlock Height="19" HorizontalAlignment="Left" Margin="14,95,0,6" Text="Shutdown" VerticalAlignment="Center" FontSize="12" Width="66" Foreground="White" FontWeight="Normal" /&gt; &lt;/Grid&gt; &lt;/Border&gt; &lt;/ControlTemplate&gt; &lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Style.Triggers&gt; &lt;EventTrigger RoutedEvent="Button.MouseEnter"&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="btnTransform" Storyboard.TargetProperty="Angle" To="-1" Duration="0:0:0.1" FillBehavior="HoldEnd" /&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;EventTrigger RoutedEvent="Button.Click"&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="btnTransform" Storyboard.TargetProperty="Angle" To="-5" Duration="0:0:0.1" FillBehavior="HoldEnd" /&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;EventTrigger RoutedEvent="Button.MouseLeave"&gt; &lt;BeginStoryboard&gt; &lt;Storyboard&gt; &lt;DoubleAnimation Storyboard.TargetName="btnShutdown_Transform" Storyboard.TargetProperty="Angle" To="0" Duration="0:0:0.3" FillBehavior="HoldEnd" /&gt; &lt;/Storyboard&gt; &lt;/BeginStoryboard&gt; &lt;/EventTrigger&gt; &lt;/Style.Triggers&gt; &lt;/Style&gt; &lt;/ResourceDictionary&gt; </code></pre> <p>Then add your resource dictionary to your App.xaml file:</p> <pre><code>&lt;Application ...&gt; &lt;Application.Resources&gt; &lt;ResourceDictionary Source="FileNameHere.xaml"/&gt; &lt;/Application.Resources&gt; &lt;/Application&gt; </code></pre> <p>Then for each button put</p> <pre><code>&lt;Button Style="{DynamicResource ButtonStyle}" ... /&gt; </code></pre>
    singulars
    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. This table or related slice is empty.
    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