ButtonStyles.xaml 5.29 KB
<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" mc:Ignorable="d">
	<ResourceDictionary.MergedDictionaries>
		<ResourceDictionary Source="..\Colors\Colors.xaml"/>
	</ResourceDictionary.MergedDictionaries>

	
	<ControlTemplate x:Key="ButtonControlTemplate" TargetType="{x:Type Button}">
		<Grid>				
			<VisualStateManager.VisualStateGroups>
				<VisualStateGroup x:Name="ValidationStates">
					<VisualState x:Name="Valid"/>
					<VisualState x:Name="InvalidFocused"/>
					<VisualState x:Name="InvalidUnfocused"/>
				</VisualStateGroup>
				<VisualStateGroup x:Name="CommonStates">
					<VisualState x:Name="Normal"/>
					<VisualState x:Name="MouseOver">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="BottomLighteningGroup">
								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
					<VisualState x:Name="Pressed">
						<Storyboard>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="BottomLighteningGroup">
								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}"/>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>
					</VisualState>
					<VisualState x:Name="Disabled">						
						<Storyboard>
							<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="Disabling">
								<DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/>
							</ObjectAnimationUsingKeyFrames>
						</Storyboard>						
					</VisualState>
				</VisualStateGroup>
				<VisualStateGroup x:Name="FocusStates">
					<VisualState x:Name="Unfocused"/>
					<VisualState x:Name="Focused"/>
				</VisualStateGroup>
			</VisualStateManager.VisualStateGroups>				
			<Border BorderThickness="1" CornerRadius="4"  
				Background="{TemplateBinding Background}"/>
			
			<Grid x:Name="BottomLighteningGroup" Margin="3,3,3,4" Visibility="Collapsed" Background="White" Opacity="0.6">
				<Grid.OpacityMask>
					<RadialGradientBrush RadiusY="0.382" Center="0.48,0.958" GradientOrigin="0.48,0.958" RadiusX="0.324">
						<GradientStop Color="Black" Offset="0"/>
						<GradientStop Offset="1"/>
					</RadialGradientBrush>
				</Grid.OpacityMask>
			</Grid>
			<Border x:Name="Shadow" CornerRadius="3" SnapsToDevicePixels="True"			    
				Margin="2" Opacity="0.5" Background="#FF1D1D1D" >
				<Border.OpacityMask>
					<RadialGradientBrush RadiusY="0.684" RadiusX="0.684">
						<GradientStop Color="Black" Offset="0.9"/>
						<GradientStop Offset="0.4"/>
					</RadialGradientBrush>
				</Border.OpacityMask>
			</Border>
			<Border BorderThickness="3" CornerRadius="2" 
				Margin="1" 
				BorderBrush="{TemplateBinding BorderBrush}">
				<Rectangle x:Name="TopLightening" Height="5" VerticalAlignment="Top" 						   
					Opacity="0.7"
					RadiusX="1" RadiusY="1"
					Fill="White"  OpacityMask="{DynamicResource WhiteToTransparent}" Margin="0" Visibility="Visible"/>
			</Border>
			<Rectangle x:Name="InnerStroke" RadiusX="1" RadiusY="1" Stroke="{DynamicResource ButtonInnerBrush}" Margin="3"/>
			<Border BorderThickness="1" CornerRadius="4"
				BorderBrush="{DynamicResource OuterBorderBrushStyle}"/>
			<Grid Margin="{TemplateBinding Padding}"
				HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"							
				VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
				ClipToBounds="False">
				<ContentPresenter />
			</Grid>
			<Border x:Name="Disabling" CornerRadius="2" Margin="2" Opacity="0.4" Background="{DynamicResource GrayLightBrush}" Visibility="Collapsed"/>
		</Grid>
	</ControlTemplate>
	
	<Style x:Key="ButtonStyle" TargetType="{x:Type Button}">
		<Setter Property="Background" Value="{DynamicResource ButtonNormalBackground}"/>
		<Setter Property="BorderBrush" Value="{StaticResource WhiteBrush}"/>
		<Setter Property="BorderThickness" Value="1"/>
		<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}"/>
		<Setter Property="HorizontalContentAlignment" Value="Center"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
		<Setter Property="Padding" Value="20,2"/>
		<Setter Property="Height" Value="34"/>
		<Setter Property="Template" Value="{StaticResource ButtonControlTemplate}"/>
		<Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Margin" Value="2"/>
        <Setter Property="FontSize" Value="12"/>
        <Style.Triggers>					
			<MultiTrigger>
				<MultiTrigger.Conditions>
					<Condition Property="IsDefault" Value="True"/>
					<Condition Property="IsPressed" Value="False"/>
				</MultiTrigger.Conditions>
				<Setter Property="Background" Value="{DynamicResource ButtonDefaultStateBackground}"/>
			</MultiTrigger>					
			<Trigger Property="IsPressed" Value="True">
				<Setter Property="Background" Value="{DynamicResource ButtonCheckedBrush}"/>
			</Trigger>
		</Style.Triggers>
	</Style>


	

</ResourceDictionary>