title: Setting the foreground[text] color of the button in a resource dictionary
body: <p>I am defining a  button style in Buttons.xaml file. Can you please tell me how to set the foreground property  of the button? I need to use a gradient as foreground property. Code is as below. Right now i am setting the gradient within the button tag.</p>
  
  <pre><code> &lt;Style x:Key="ButtonCancel" TargetType="{x:Type Button}"&gt;
  
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type Button}"&gt;
                      &lt;ControlTemplate.Resources&gt;
                          &lt;Storyboard x:Key="Storyboard1"&gt;
                              &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="0.68"/&gt;
                              &lt;/DoubleAnimationUsingKeyFrames&gt;
                              &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"/&gt;
                              &lt;/DoubleAnimationUsingKeyFrames&gt;
                              &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"/&gt;
                              &lt;/DoubleAnimationUsingKeyFrames&gt;
                              &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1.1"/&gt;
                              &lt;/DoubleAnimationUsingKeyFrames&gt;
                          &lt;/Storyboard&gt;
                          &lt;Storyboard x:Key="Storyboard_Copy1"&gt;
                              &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.Opacity)"&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.68"/&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/&gt;
                              &lt;/DoubleAnimationUsingKeyFrames&gt;
                              &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="1.1"/&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/&gt;
                              &lt;/DoubleAnimationUsingKeyFrames&gt;
                              &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)"&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="1.1"/&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/&gt;
                              &lt;/DoubleAnimationUsingKeyFrames&gt;
                              &lt;DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)"&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00" Value="1.1"/&gt;
                                  &lt;SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1"/&gt;
                              &lt;/DoubleAnimationUsingKeyFrames&gt;
                          &lt;/Storyboard&gt;
                      &lt;/ControlTemplate.Resources&gt;
                      &lt;Grid&gt;
                          &lt;Image x:Name="image" Source="../images/UnCategorized/Red_Oval_Button_With_Cross.png" Stretch="Fill" RenderTransformOrigin="0.5,0.5"&gt;
                              &lt;Image.RenderTransform&gt;
                                  &lt;TransformGroup&gt;
                                      &lt;ScaleTransform/&gt;
                                      &lt;SkewTransform/&gt;
                                      &lt;RotateTransform/&gt;
                                      &lt;TranslateTransform/&gt;
                                  &lt;/TransformGroup&gt;
                              &lt;/Image.RenderTransform&gt;
                          &lt;/Image&gt;
                          &lt;ContentPresenter x:Name="contentPresenter"   HorizontalAlignment="Center" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" RecognizesAccessKey="True" Content="CANCEL" RenderTransformOrigin="0.5,0.5"&gt;
                              &lt;ContentPresenter.RenderTransform&gt;
                                  &lt;TransformGroup&gt;
                                      &lt;ScaleTransform/&gt;
                                      &lt;SkewTransform/&gt;
                                      &lt;RotateTransform/&gt;
                                      &lt;TranslateTransform/&gt;
                                  &lt;/TransformGroup&gt;
                              &lt;/ContentPresenter.RenderTransform&gt;
  
                          &lt;/ContentPresenter&gt;
                      &lt;/Grid&gt;
                      &lt;ControlTemplate.Triggers&gt;
                          &lt;Trigger Property="IsFocused" Value="True"/&gt;
                          &lt;Trigger Property="IsDefaulted" Value="True"/&gt;
                          &lt;Trigger Property="IsMouseOver" Value="True"&gt;
                              &lt;Trigger.ExitActions&gt;
                                  &lt;BeginStoryboard x:Name="Storyboard_Copy1_BeginStoryboard" Storyboard="{StaticResource Storyboard_Copy1}"/&gt;
                              &lt;/Trigger.ExitActions&gt;
                              &lt;Trigger.EnterActions&gt;
                                  &lt;BeginStoryboard Storyboard="{StaticResource Storyboard1}"/&gt;
                              &lt;/Trigger.EnterActions&gt;
                          &lt;/Trigger&gt;
                          &lt;Trigger Property="IsPressed" Value="True"/&gt;
                          &lt;Trigger Property="IsEnabled" Value="False"/&gt;
                      &lt;/ControlTemplate.Triggers&gt;
                  &lt;/ControlTemplate&gt;
  
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <hr>
  
  <pre><code> &lt;Button Style="{DynamicResource ButtonCancel}" Click="btnCancel_Clicked" FontFamily="Tw Cen MT" FontSize="18" FontWeight="Bold" Width="144" Name="btnCancel"
                  HorizontalAlignment="Right" Grid.Row="1"  Grid.Column="1" Margin="0,73.5,0,55.5"&gt;
              &lt;Button.OpacityMask&gt;
                  &lt;LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"&gt;
                      &lt;GradientStop Color="#9B000000" Offset="0"/&gt;
                      &lt;GradientStop Color="White" Offset="1"/&gt;
                  &lt;/LinearGradientBrush&gt;
              &lt;/Button.OpacityMask&gt;
  
          &lt;/Button&gt;
  </code></pre>