Skip to content

Instantly share code, notes, and snippets.

@JohanLarsson
Last active November 10, 2019 18:52
Show Gist options
  • Save JohanLarsson/21cbffa73b6e3d5fce10c186095724f5 to your computer and use it in GitHub Desktop.
Save JohanLarsson/21cbffa73b6e3d5fce10c186095724f5 to your computer and use it in GitHub Desktop.
<Window.Resources>
<Style TargetType="Button">
<Setter Property="Padding" Value="6,4" />
<Setter Property="Background" Value="#0073CF" />
<Setter Property="Foreground" Value="White" />
<Setter Property="BorderBrush" Value="#0073CF" />
<Setter Property="BorderThickness" Value="2" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
Background="{TemplateBinding Background}"
BorderThickness="0"
RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<ScaleTransform x:Name="ScaleTransform" ScaleX="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(local:Zoom.Value)}" ScaleY="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(local:Zoom.Value)}" />
</Border.RenderTransform>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter
Margin="{Binding RelativeSource={RelativeSource TemplatedParent}}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" Value="#737373" />
<Setter Property="Foreground" Value="Black" />
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(local:Zoom.Value)"
To="0.98"
Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(local:Zoom.Value)"
To="1"
Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsMouseOver" Value="True" />
<Condition Property="IsPressed" Value="False" />
</MultiTrigger.Conditions>
<Setter Property="BorderBrush" Value="#737373" />
<MultiTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(local:Zoom.Value)"
To="1.02"
Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</MultiTrigger.EnterActions>
<MultiTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="(local:Zoom.Value)"
To="1"
Duration="0:0:0.2" />
</Storyboard>
</BeginStoryboard>
</MultiTrigger.ExitActions>
</MultiTrigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<Button
Width="200"
Height="100"
Margin="5"
HorizontalAlignment="Left"
VerticalAlignment="Top">
Activate
</Button>
<Button
Width="200"
Height="100"
Margin="5"
HorizontalAlignment="Left"
VerticalAlignment="Top">
Activate
</Button>
</StackPanel>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment