title: WPF add new Slider style cause XamlParseException
body: <p>i found <a href="http://www.wpfhelper.com/index.php/component/content/article/23-modern-ui-for-wpf/android-ui-for-wpf/25-wpf-slider-style-inspired-by-android" rel="nofollow">this</a> <code>slider</code> style that i want to add.</p>
  
  <p>i added all the 3 styles inside my <code>Window.Resources</code> and also put in the first style the 2 templates:</p>
  
  <pre><code>    &lt;Style TargetType="{x:Type Slider}"&gt;
          &lt;Setter Property="FocusVisualStyle" Value="{StaticResource MyFocusVisualStyte}" /&gt;
          &lt;Setter Property="SnapsToDevicePixels" Value="true" /&gt;
          &lt;Setter Property="OverridesDefaultStyle" Value="true" /&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type Slider}"&gt;
                      &lt;Grid Margin="5"&gt;
                          &lt;Grid.ColumnDefinitions&gt;
                              &lt;ColumnDefinition Width="Auto" /&gt;
                              &lt;ColumnDefinition Width="Auto" MinWidth="{TemplateBinding MinWidth}"/&gt;
                              &lt;ColumnDefinition Width="Auto"/&gt;
                          &lt;/Grid.ColumnDefinitions&gt;
                          &lt;TickBar x:Name="TopTick" Visibility="Collapsed" Fill="LightGray" Placement="Left" SnapsToDevicePixels="True"
               Width="4" Margin="0,0,2,0" /&gt;
                          &lt;Border x:Name="TrackBackground"
              Grid.Column="1"
              Margin="0,10"
              BorderThickness="2"
              BorderBrush="LightGray"
              HorizontalAlignment="Center" Width="4" /&gt;
                          &lt;Track x:Name="PART_Track" Grid.Column="1"&gt;
                              &lt;Track.DecreaseRepeatButton&gt;
                                  &lt;RepeatButton Command="{x:Static Slider.DecreaseLarge}"  Style="{StaticResource SliderRepeatButtonStyle}" /&gt;
                              &lt;/Track.DecreaseRepeatButton&gt;
                              &lt;Track.IncreaseRepeatButton&gt;
                                  &lt;RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource SliderRepeatButtonStyle}"/&gt;
                              &lt;/Track.IncreaseRepeatButton&gt;
                              &lt;Track.Thumb&gt;
                                  &lt;Thumb x:Name="Thumb" Style="{StaticResource SliderThumbStyle}" /&gt;
                              &lt;/Track.Thumb&gt;
                          &lt;/Track&gt;
                          &lt;TickBar x:Name="BottomTick" Grid.Column="2" Visibility="Collapsed" Fill="LightGray" Placement="Right"
               Width="4" Margin="2,0,0,0" SnapsToDevicePixels="True" /&gt;
                      &lt;/Grid&gt;
                      &lt;ControlTemplate.Triggers&gt;
                          &lt;Trigger Property="TickPlacement" Value="TopLeft"&gt;
                              &lt;Setter TargetName="TopTick" Property="Visibility" Value="Visible" /&gt;
                          &lt;/Trigger&gt;
                          &lt;Trigger Property="TickPlacement" Value="BottomRight"&gt;
                              &lt;Setter TargetName="BottomTick" Property="Visibility" Value="Visible" /&gt;
                          &lt;/Trigger&gt;
                          &lt;Trigger Property="TickPlacement" Value="Both"&gt;
                              &lt;Setter TargetName="TopTick" Property="Visibility" Value="Visible" /&gt;
                              &lt;Setter TargetName="BottomTick" Property="Visibility" Value="Visible" /&gt;
                          &lt;/Trigger&gt;
                      &lt;/ControlTemplate.Triggers&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type Slider}"&gt;
                      &lt;Grid Margin="5"&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition Height="Auto" /&gt;
                              &lt;RowDefinition Height="Auto" MinHeight="{TemplateBinding MinHeight}"/&gt;
                              &lt;RowDefinition Height="Auto"/&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;TickBar x:Name="TopTick" Visibility="Collapsed" Fill="LightGray" Placement="Top" SnapsToDevicePixels="True"
               Height="4" Margin="0,0,0,2" /&gt;
                          &lt;Border x:Name="TrackBackground"
              Grid.Row="1"
              Margin="10,0"
              BorderThickness="2"
              BorderBrush="LightGray"
              VerticalAlignment="Center" Height="4" /&gt;
                          &lt;Track x:Name="PART_Track" Grid.Row="1"&gt;
                              &lt;Track.DecreaseRepeatButton&gt;
                                  &lt;RepeatButton Command="{x:Static Slider.DecreaseLarge}"  Style="{StaticResource SliderRepeatButtonStyle}" /&gt;
                              &lt;/Track.DecreaseRepeatButton&gt;
                              &lt;Track.IncreaseRepeatButton&gt;
                                  &lt;RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource SliderRepeatButtonStyle}"/&gt;
                              &lt;/Track.IncreaseRepeatButton&gt;
                              &lt;Track.Thumb&gt;
                                  &lt;Thumb x:Name="Thumb" Style="{StaticResource SliderThumbStyle}" /&gt;
                              &lt;/Track.Thumb&gt;
                          &lt;/Track&gt;
                          &lt;TickBar x:Name="BottomTick" Grid.Row="2" Visibility="Collapsed" Fill="LightGray" Placement="Bottom"
               SnapsToDevicePixels="True" Height="4" Margin="0,2,0,0"/&gt;
                      &lt;/Grid&gt;
                      &lt;ControlTemplate.Triggers&gt;
                          &lt;Trigger Property="TickPlacement" Value="TopLeft"&gt;
                              &lt;Setter TargetName="TopTick" Property="Visibility" Value="Visible" /&gt;
                          &lt;/Trigger&gt;
                          &lt;Trigger Property="TickPlacement" Value="BottomRight"&gt;
                              &lt;Setter TargetName="BottomTick" Property="Visibility" Value="Visible" /&gt;
                          &lt;/Trigger&gt;
                          &lt;Trigger Property="TickPlacement" Value="Both"&gt;
                              &lt;Setter TargetName="TopTick" Property="Visibility" Value="Visible" /&gt;
                              &lt;Setter TargetName="BottomTick" Property="Visibility" Value="Visible" /&gt;
                          &lt;/Trigger&gt;
                      &lt;/ControlTemplate.Triggers&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
          &lt;Style.Triggers&gt;
              &lt;Trigger Property="Orientation" Value="Horizontal"&gt;
                  &lt;Setter Property="MinWidth" Value="104" /&gt;
                  &lt;Setter Property="MinHeight" Value="21" /&gt;
                  &lt;Setter Property="Template" Value="{StaticResource HorizontalSlider}" /&gt;
              &lt;/Trigger&gt;
              &lt;Trigger Property="Orientation" Value="Vertical"&gt;
                  &lt;Setter Property="MinWidth" Value="21" /&gt;
                  &lt;Setter Property="MinHeight" Value="104" /&gt;
                  &lt;Setter Property="Template" Value="{StaticResource VerticalSlider}" /&gt;
              &lt;/Trigger&gt;
          &lt;/Style.Triggers&gt;
      &lt;/Style&gt;
      &lt;Style TargetType="{x:Type RepeatButton}"&gt;
          &lt;Setter Property="OverridesDefaultStyle" Value="true"/&gt;
          &lt;Setter Property="IsTabStop" Value="false"/&gt;
          &lt;Setter Property="Focusable" Value="false"/&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type RepeatButton}"&gt;
                      &lt;Rectangle Fill="Transparent"/&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
      &lt;Style TargetType="{x:Type Thumb}"&gt;
          &lt;Setter Property="OverridesDefaultStyle" Value="True"/&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type Thumb}"&gt;
                      &lt;Grid&gt;
                          &lt;Border Name="outerBorder"
                          Background="#5534b4e3"
                          BorderBrush="#5534b4e3"
                          Height="26" Width="26" Opacity="1" BorderThickness="2" CornerRadius="13"/&gt;
                          &lt;Border Name="innerBorder"
                          Background="#FF34b4e3"
                          BorderBrush="#FF34b4e3"
                          Height="10" Width="10" CornerRadius="5" Opacity="1" /&gt;
                      &lt;/Grid&gt;
                      &lt;ControlTemplate.Triggers&gt;
                          &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                              &lt;Setter TargetName="outerBorder" Property="BorderBrush" Value="#BB34b4e3" /&gt;
                          &lt;/Trigger&gt;
                          &lt;Trigger Property="IsEnabled" Value="False"&gt;
                              &lt;Setter TargetName="outerBorder" Property="Background" Value="#55ACACAC" /&gt;
                              &lt;Setter TargetName="outerBorder" Property="BorderBrush" Value="#55ACACAC" /&gt;
                              &lt;Setter TargetName="innerBorder" Property="Width" Value="4" /&gt;
                              &lt;Setter TargetName="innerBorder" Property="Height" Value="4" /&gt;
                              &lt;Setter TargetName="innerBorder" Property="CornerRadius" Value="2" /&gt;
                          &lt;/Trigger&gt;
                      &lt;/ControlTemplate.Triggers&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
      &lt;Style x:Key="MyFocusVisualStyte" &gt;
          &lt;Setter Property="Control.Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate&gt;
                      &lt;Rectangle x:Name="FocusStyle" StrokeDashArray="4 4" RadiusX="5" RadiusY="5" Fill="Transparent"
                         Stroke="#99029cc7" StrokeThickness="1" /&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>because i want to give all my application <code>sliders</code> the same look i removed the <code>x:key</code> from all except the <code>x:Key="MyFocusVisualStyte"</code> in the first style because in this case this line:</p>
  
  <pre><code>&lt;Setter Property="FocusVisualStyle" Value="{StaticResource MyFocusVisualStyte}" /&gt;
  </code></pre>
  
  <p>I have error: The resource <code>MyFocusVisualStyte</code> could not be resolved.
  And after add <code>slider</code>:</p>
  
  <pre><code>&lt;Slider Margin="454,122,0,543" /&gt;
  </code></pre>
  
  <p>I can see in the designer this <code>slider</code>:</p>
  
  <p><a href="http://oi57.tinypic.com/2ijcxd.jpg" rel="nofollow">http://oi57.tinypic.com/2ijcxd.jpg</a></p>
  
  <p>but when ry to run my application i have <code>XamlParseException</code>:</p>
  
  <blockquote>
    <p>A first chance exception of type
    'System.Windows.Markup.XamlParseException' occurred in
    PresentationFramework.dll</p>
    
    <p>Additional information: 'Initialization of
    'System.Windows.Controls.Slider' threw an exception.' Line number
    '921' and line position '17'.</p>
  </blockquote>
  
  <p>What i am doing wrong ?</p>
  
  <p></p>