<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
					xmlns:local="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
					xmlns:themes="clr-namespace:Xceed.Wpf.Toolkit.Themes;assembly=Xceed.Wpf.Toolkit">

	<!-- Identical to Wpf Toolkit's standard ButtonSpinner, but support high DPI better for up/down arrows 
	
	We use half point values so that when the edges are anti-aliased it looks good on both regular and high DPI.
	The 'flat' side of the arrow is also aligned to a whole pixel to make that edge crisp on regular DPI.
	-->
	<Geometry x:Key="UpArrowGeometry">M0,5 L4.5,.5 9,5 6,5 4.5,3.5 3,5 z</Geometry>
	<Geometry x:Key="DownArrowGeometry">M0,0 L3,0 4.5,1.5 6,0 9,0 4.5,4.5 z</Geometry>

	<DataTemplate x:Key="IncreaseGlyphNormalKey">
		<Path Width="9"
			Height="5"
            Data="{StaticResource UpArrowGeometry}"
            Fill="{DynamicResource {x:Static themes:ResourceKeys.GlyphNormalForegroundKey}}"
            SnapsToDevicePixels="True"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Focusable="False">
		</Path>
	</DataTemplate>
	<DataTemplate x:Key="DecreaseGlyphNormalKey">
		<Path Width="9"
            Height="5"
            Data="{StaticResource DownArrowGeometry}"
            Fill="{DynamicResource {x:Static themes:ResourceKeys.GlyphNormalForegroundKey}}"
            SnapsToDevicePixels="True"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Focusable="False">
		</Path>
	</DataTemplate>

	<DataTemplate x:Key="IncreaseGlyphDisabledKey">
		<Path Width="9"
            Height="5"
            Data="{StaticResource UpArrowGeometry}"
            Fill="{DynamicResource {x:Static themes:ResourceKeys.GlyphDisabledForegroundKey}}"
            SnapsToDevicePixels="True"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Focusable="False" />
	</DataTemplate>

	<DataTemplate x:Key="DecreaseGlyphDisabledKey">
		<Path Width="9"
            Height="5"
            Data="{StaticResource DownArrowGeometry}"
            Fill="{DynamicResource {x:Static themes:ResourceKeys.GlyphDisabledForegroundKey}}"
            SnapsToDevicePixels="True"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Focusable="False" />
	</DataTemplate>

	<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />

	<Style TargetType="{x:Type local:ButtonSpinner}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type local:ButtonSpinner}">
					<Border x:Name="Border" SnapsToDevicePixels="True" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" >
						<Grid>
							<Grid.ColumnDefinitions>
								<ColumnDefinition x:Name="firstContentColumn" Width="*" />
								<ColumnDefinition x:Name="secondContentColumn" Width="Auto" />
							</Grid.ColumnDefinitions>
							<ContentPresenter x:Name="contentPresenter" Focusable="False" Margin="{TemplateBinding Padding}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />

							<Grid x:Name="gridContent" Grid.Column="1" Visibility="{TemplateBinding ShowButtonSpinner, Converter={StaticResource BooleanToVisibilityConverter}}" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
								<Grid.RowDefinitions>
									<RowDefinition Height="*" />
									<RowDefinition Height="*" />
								</Grid.RowDefinitions>

								<RepeatButton x:Name="PART_IncreaseButton"
                                   Style="{DynamicResource {x:Static themes:ResourceKeys.SpinnerButtonStyleKey}}"
                                   IsTabStop="{TemplateBinding IsTabStop}" ContentTemplate="{StaticResource IncreaseGlyphNormalKey}" />

								<RepeatButton x:Name="PART_DecreaseButton"
                                   Grid.Row="1"
                                   Style="{DynamicResource {x:Static themes:ResourceKeys.SpinnerButtonStyleKey}}"
                                   IsTabStop="{TemplateBinding IsTabStop}" ContentTemplate="{StaticResource DecreaseGlyphNormalKey}" />

							</Grid>
						</Grid>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsMouseOver" Value="True">
							<Setter Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ControlMouseOverBorderKey}}" />
						</Trigger>
						<Trigger Property="IsKeyboardFocusWithin" Value="True">
							<Setter Property="BorderBrush" Value="{DynamicResource {x:Static themes:ResourceKeys.ControlSelectedBorderKey}}" />
						</Trigger>
						<Trigger Property="IsEnabled" Value="False">
							<Setter Property="Background" Value="{DynamicResource {x:Static themes:ResourceKeys.ControlDisabledBackgroundKey}}" />
						</Trigger>
						<Trigger SourceName="PART_IncreaseButton" Property="IsEnabled" Value="False">
							<Setter TargetName="PART_IncreaseButton" Property="ContentTemplate" Value="{StaticResource IncreaseGlyphDisabledKey}" />
						</Trigger>
						<Trigger SourceName="PART_DecreaseButton" Property="IsEnabled" Value="False">
							<Setter TargetName="PART_DecreaseButton" Property="ContentTemplate" Value="{StaticResource DecreaseGlyphDisabledKey}" />
						</Trigger>
						<Trigger Property="ButtonSpinnerLocation"
                                 Value="Left">
							<Setter TargetName="firstContentColumn"
                                   Property="Width"
                                   Value="Auto" />
							<Setter TargetName="secondContentColumn"
                                   Property="Width"
                                   Value="*" />
							<Setter TargetName="contentPresenter"
                                   Property="Grid.Column"
                                   Value="1" />
							<Setter TargetName="gridContent"
                                   Property="Grid.Column"
                                   Value="0" />
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>