title: Change background linear gradient Button style
body: <p>I want to change Button's background linear gradient color,</p>
  
  <p>the maintain code if Border.Background,</p>
  
  <p>for Case 1</p>
  
  <p><a href="https://i.stack.imgur.com/AcJh7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AcJh7.png" alt="enter image description here"></a></p>
  
  <p>to impletenment must fix as follow</p>
  
  <pre><code>&lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                                  &lt;GradientStop Color="{DynamicResource ControlLightColor}" Offset="0" /&gt;
                                  &lt;GradientStop Color="{DynamicResource ControlLightColor}" Offset="1" /&gt;
                              &lt;/LinearGradientBrush&gt;
  </code></pre>
  
  <p>for case 2</p>
  
  <p><a href="https://i.stack.imgur.com/5SzKT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5SzKT.png" alt="enter image description here"></a></p>
  
  <p>to impletenment must fix as follow</p>
  
  <pre><code>&lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                                  &lt;GradientStop Color="{DynamicResource ControlMediumColor}" Offset="0" /&gt;
                                  &lt;GradientStop Color="{DynamicResource ControlLightColor}" Offset="0.5" /&gt;
                                  &lt;GradientStop Color="{DynamicResource ControlMediumColor}" Offset="1" /&gt;
                              &lt;/LinearGradientBrush&gt;
  </code></pre>
  
  <p>How can I fix the Border.Background, to staticresource relation to</p>
  
  <p>button style in xaml file</p>
  
  <p>11/28 Update</p>
  
  <p>I want to create 2 normal button, at the same application</p>
  
  <p>how to using the key keyword to handle Border.Background.</p>
  
  <p>As follow is whole code of button style</p>
  
  <pre><code>&lt;!-- Button --&gt;
      &lt;Style x:Key="ButtonW2B" TargetType="Button"&gt;
          &lt;Setter Property="SnapsToDevicePixels" Value="true" /&gt;
          &lt;Setter Property="OverridesDefaultStyle" Value="true" /&gt;
          &lt;Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}" /&gt;
          &lt;Setter Property="MinHeight" Value="5" /&gt;
          &lt;Setter Property="MinWidth" Value="5" /&gt;
          &lt;Setter Property="Foreground" Value="DeepSkyBlue" /&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="Button"&gt;
                      &lt;Border TextBlock.Foreground="{TemplateBinding Foreground}"
              x:Name="Border"
              CornerRadius="2"
              BorderThickness="1"&gt;
                          &lt;Border.BorderBrush&gt; &lt;!--外框顏色--&gt;
                              &lt;LinearGradientBrush StartPoint="0,0" EndPoint="0,1"&gt;
                                  &lt;LinearGradientBrush.GradientStops&gt;
                                      &lt;GradientStopCollection&gt;
                                          &lt;GradientStop Color="{DynamicResource BorderMediumColor}" Offset="0" /&gt;
                                          &lt;GradientStop Color="{DynamicResource BorderLightColor}" Offset="0.5" /&gt;
                                          &lt;GradientStop Color="{DynamicResource BorderMediumColor}" Offset="1.0" /&gt;
                                      &lt;/GradientStopCollection&gt;
                                  &lt;/LinearGradientBrush.GradientStops&gt;
                              &lt;/LinearGradientBrush&gt;
                          &lt;/Border.BorderBrush&gt;
  
                          &lt;!--&lt;Border.Background&gt;--&gt;
                          &lt;!--按鍵底色--&gt;
                          &lt;!--&lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                                  &lt;GradientStop Color="{DynamicResource ControlLightColor}" Offset="0" /&gt;
                                  &lt;GradientStop Color="{DynamicResource ControlLightColor}" Offset="1" /&gt;
                              &lt;/LinearGradientBrush&gt;
                          &lt;/Border.Background&gt;--&gt;
  
                          &lt;VisualStateManager.VisualStateGroups&gt;
                              &lt;VisualStateGroup x:Name="CommonStates"&gt;
                                  &lt;VisualStateGroup.Transitions&gt;
                                      &lt;VisualTransition GeneratedDuration="0:0:0.5" /&gt;
                                      &lt;VisualTransition GeneratedDuration="0" To="Pressed" /&gt;
                                  &lt;/VisualStateGroup.Transitions&gt;
                                  &lt;VisualState x:Name="Normal" /&gt;
                                  &lt;VisualState x:Name="MouseOver"&gt;
                                      &lt;Storyboard&gt;
                                          &lt;ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).
                    (GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                              Storyboard.TargetName="Border"&gt;
                                              &lt;EasingColorKeyFrame KeyTime="0"
                                       Value="{StaticResource ControlMouseOverColor}" /&gt;
                                          &lt;/ColorAnimationUsingKeyFrames&gt;
                                      &lt;/Storyboard&gt;
                                  &lt;/VisualState&gt;
                                  &lt;VisualState x:Name="Pressed"&gt;
                                      &lt;Storyboard&gt;
                                          &lt;ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).
                    (GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                              Storyboard.TargetName="Border"&gt;
                                              &lt;EasingColorKeyFrame KeyTime="0"
                                       Value="{StaticResource ControlPressedColor}" /&gt;
                                          &lt;/ColorAnimationUsingKeyFrames&gt;
                                          &lt;ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).
                    (GradientBrush.GradientStops)[0].(GradientStop.Color)"
                                              Storyboard.TargetName="Border"&gt;
                                              &lt;EasingColorKeyFrame KeyTime="0"
                                       Value="{StaticResource PressedBorderDarkColor}" /&gt;
                                          &lt;/ColorAnimationUsingKeyFrames&gt;
                                          &lt;ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).
                    (GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                              Storyboard.TargetName="Border"&gt;
                                              &lt;EasingColorKeyFrame KeyTime="0"
                                       Value="{StaticResource PressedBorderLightColor}" /&gt;
                                          &lt;/ColorAnimationUsingKeyFrames&gt;
                                      &lt;/Storyboard&gt;
                                  &lt;/VisualState&gt;
                                  &lt;VisualState x:Name="Disabled"&gt;
                                      &lt;Storyboard&gt;
                                          &lt;ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Panel.Background).
                    (GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                              Storyboard.TargetName="Border"&gt;
                                              &lt;EasingColorKeyFrame KeyTime="0"
                                       Value="{StaticResource DisabledControlDarkColor}" /&gt;
                                          &lt;/ColorAnimationUsingKeyFrames&gt;
                                          &lt;ColorAnimationUsingKeyFrames
                    Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)"
                                              Storyboard.TargetName="Border"&gt;
                                              &lt;EasingColorKeyFrame KeyTime="0"
                                       Value="{StaticResource DisabledForegroundColor}" /&gt;
                                          &lt;/ColorAnimationUsingKeyFrames&gt;
                                          &lt;ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.BorderBrush).
                    (GradientBrush.GradientStops)[1].(GradientStop.Color)"
                                              Storyboard.TargetName="Border"&gt;
                                              &lt;EasingColorKeyFrame KeyTime="0"
                                       Value="{StaticResource DisabledBorderDarkColor}" /&gt;
                                          &lt;/ColorAnimationUsingKeyFrames&gt;
                                      &lt;/Storyboard&gt;
                                  &lt;/VisualState&gt;
                              &lt;/VisualStateGroup&gt;
                          &lt;/VisualStateManager.VisualStateGroups&gt;
                          &lt;ContentPresenter Margin="2"
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center"
                          RecognizesAccessKey="True" /&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>