<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:controls="clr-namespace:XamlTheme.Controls"
                    xmlns:themes="clr-namespace:XamlTheme"> 

    <Style TargetType="{x:Type controls:NumericBox}">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="BorderBrush" Value="#141414" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="FontSize" Value="12" />
        <Setter Property="Foreground" Value="#141414" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="MinHeight" Value="25" />
        <Setter Property="MinWidth" Value="40" />
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
        <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled" />
        <Setter Property="SnapsToDevicePixels" Value="true" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:NumericBox}">
                    <Grid Background="#00000000">
                        <Border x:Name="Base"
                                Background="{TemplateBinding Background}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" >
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="auto"/>
                                </Grid.ColumnDefinitions>
                                <TextBox x:Name="PART_TextBox"  
                                         Padding="{TemplateBinding Padding}"
                                         InputMethod.IsInputMethodEnabled="False"
                                         MinHeight="{TemplateBinding MinHeight}"
                                         HorizontalAlignment="Stretch"
                                         VerticalAlignment="Stretch"
                                         HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                                         VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" 
                                         TextAlignment="{TemplateBinding TextAlignment}"
                                         Background="{x:Null}"
                                         BorderThickness="0"
                                         FocusVisualStyle="{x:Null}"
                                         Focusable="{TemplateBinding Focusable}"
                                         FontFamily="{TemplateBinding FontFamily}"
                                         FontSize="{TemplateBinding FontSize}"
                                         Foreground="{TemplateBinding Foreground}"
                                         HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                                         IsReadOnly="{TemplateBinding IsReadOnly}"
                                         IsTabStop="{TemplateBinding IsTabStop}"
                                         SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                         TabIndex="{TemplateBinding TabIndex}"
                                         VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" 
                                         Style="{DynamicResource {x:Static themes:ResourceKeys.NormalTextBoxStyleKey}}"/>
                                <Grid Grid.Column="1" Width="{TemplateBinding UpDownButtonsWidth}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition/>
                                        <RowDefinition Height="1"/>
                                        <RowDefinition/>
                                    </Grid.RowDefinitions>
                                    <RepeatButton x:Name="PART_NumericUp"
                                                  Grid.Row="0"
                                                  Margin="0,1,1,0"                                           
                                                  Delay="{TemplateBinding Delay}"
                                                  Foreground="{TemplateBinding Foreground}"
                                                  IsTabStop="False"
                                                  Command="{x:Static controls:NumericBox.IncreaseCommand}"
                                                  Style="{DynamicResource {x:Static themes:ResourceKeys.NormalRepeatButtonStyleKey}}">
                                        <Path Width="11" Height="7" Stretch="Fill"
                                              Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=RepeatButton}}"
                                              Data="M16,0L32,19.7 16,9.6 0,19.7z"/>
                                    </RepeatButton>
                                    <RepeatButton x:Name="PART_NumericDown"
                                                  Grid.Row="2"    
                                                  Margin="0,0,1,1" 
                                                  Delay="{TemplateBinding Delay}"
                                                  Foreground="{TemplateBinding Foreground}"
                                                  IsTabStop="False"
                                                  Command="{x:Static controls:NumericBox.DecreaseCommand}"
                                                  Style="{DynamicResource {x:Static themes:ResourceKeys.NormalRepeatButtonStyleKey}}">
                                        <Path Width="11" Height="7" Stretch="Fill"
                                              Fill="{Binding Foreground, RelativeSource={RelativeSource AncestorType=RepeatButton}}"
                                              Data="M0,0 L20.25,19.5 40.5,0 20.25,38 z"/>
                                    </RepeatButton>
                                </Grid>
                            </Grid>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="UpDownButtonsWidth" Value="0"> 
                            <Setter TargetName="PART_NumericDown" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="PART_NumericUp" Property="Visibility" Value="Collapsed" />
                        </Trigger>
                        <Trigger Property="IsReadOnly" Value="True">
                            <Setter Property="Focusable" Value="False"/>
                            <Setter TargetName="PART_NumericDown" Property="IsEnabled" Value="False" />
                            <Setter TargetName="PART_NumericUp" Property="IsEnabled" Value="False" />
                        </Trigger>
                        <Trigger Property="IsKeyboardFocused" SourceName="PART_TextBox" Value="true">
                            <Setter Property="BorderBrush" Value="#007ACC"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>