Created
July 10, 2012 15:11
-
-
Save alimbada/3083937 to your computer and use it in GitHub Desktop.
Metro Style for WPF Button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | |
<Style | |
x:Key="ButtonFocusVisual"> | |
<Setter | |
Property="Control.Template"> | |
<Setter.Value> | |
<ControlTemplate> | |
<Rectangle Margin="2" SnapsToDevicePixels="true" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2" /> | |
</ControlTemplate> | |
</Setter.Value> | |
</Setter> | |
</Style> | |
<Style x:Key="MetroButton" TargetType="{x:Type Button}"> | |
<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/> | |
<Setter Property="Background" Value="#EEEEEEEE"/> | |
<Setter Property="Foreground" Value="Black"/> | |
<Setter Property="HorizontalContentAlignment" Value="Center"/> | |
<Setter Property="VerticalContentAlignment" Value="Center"/> | |
<Setter Property="Padding" Value="10 5"/> | |
<Setter Property="FontSize" Value="14" /> | |
<Setter Property="BorderThickness" Value="2" /> | |
<Setter Property="Template"> | |
<Setter.Value> | |
<ControlTemplate TargetType="{x:Type Button}"> | |
<Grid> | |
<Border | |
x:Name="Border" | |
Background="{TemplateBinding Background}" | |
BorderBrush="{TemplateBinding BorderBrush}" | |
BorderThickness="{TemplateBinding BorderThickness}" /> | |
<ContentPresenter | |
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | |
Margin="{TemplateBinding Padding}" | |
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | |
RecognizesAccessKey="True" /> | |
</Grid> | |
<ControlTemplate.Triggers> | |
<Trigger Property="IsPressed" Value="True"> | |
<Setter Property="OpacityMask" Value="#AA888888"/> | |
<Setter Property="Margin" Value="2 1" /> | |
</Trigger> | |
<Trigger Property="IsMouseOver" Value="True"> | |
<Setter Property="BorderThickness" Value="0"/> | |
<!--<Setter Property="Background" Value="DimGray"/>--> | |
<Setter Property="Foreground" Value="White"/> | |
</Trigger> | |
<Trigger Property="IsEnabled" Value="false"> | |
<Setter Property="Foreground" Value="#ADADAD"/> | |
</Trigger> | |
</ControlTemplate.Triggers> | |
</ControlTemplate> | |
</Setter.Value> | |
</Setter> | |
</Style> | |
</ResourceDictionary> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And, to use the style, remember: Style="{StaticResource MetroButton}"