title: WPF. Add image and text into button using c#
body: <p>I have big button (Gray border),where I have to add an image using c# and also I have to add text under the image also using c# (there is also red button inside the button) ,I really do not understand how to add image in c# code (and text) and how to call it. It have to be something like button.content=image... I found some information, but I do not understand what to write in c#?</p>
  
  <p>my xaml:</p>
  
  <pre><code>  &lt;Style x:Key="ButtonStyle"  TargetType="{x:Type Button}"&gt;
          &lt;Setter Property="Foreground" Value="Black"/&gt;
          &lt;Setter Property="HorizontalContentAlignment" Value="Center"/&gt;
          &lt;Setter Property="FontSize" Value="20px" /&gt;
          &lt;Setter Property="ToolTipService.IsEnabled" Value="False"/&gt;
          &lt;Setter Property="Template"&gt;
              &lt;Setter.Value&gt;
                  &lt;ControlTemplate TargetType="{x:Type Button}"&gt;
                      &lt;Border BorderBrush="#E6E6E6" BorderThickness="1"&gt;
                          &lt;Grid x:Name="btnGrid" Width="320px" Height="320px"&gt;
  
                              &lt;Image  Grid.Row="0"
                                    Stretch="Fill"
                                    HorizontalAlignment="Center"
                                    Width="131" 
                                    Height="98"
                                    Margin="0,69px,0,0"
                                    Source="{TemplateBinding Content}" /&gt;
                              &lt;TextBlock  x:Name="btnText" Grid.Row="0"
                                        Text="{TemplateBinding ToolTip}"
                                        HorizontalAlignment="Center" 
                                        Margin="0,207,0,0"
                                        TextAlignment="Center"
                                        TextWrapping="Wrap"
                                        FontFamily="{TemplateBinding FontFamily}"
                                        FontSize="{TemplateBinding FontSize}"
                                        Foreground="{TemplateBinding Foreground}" 
                                        FontStretch="{TemplateBinding FontStretch}" /&gt;
                              &lt;Button  x:Name="btnButton" Grid.Row="2" Style="{DynamicResource MetroButtonStyle}" 
                                        ToolTip="{TemplateBinding ToolTip}"
                                        HorizontalAlignment="Center" 
                                        VerticalAlignment="Center" 
                                        Background="#F86C4D"
                                        Margin="0,238px,0,0"
                                 Height="50"
                                 Width="150"
                                        Foreground="White"
                                        FontFamily="{TemplateBinding FontFamily}"
  
                                         /&gt;
                          &lt;/Grid&gt;
                      &lt;/Border&gt;
                  &lt;/ControlTemplate&gt;
              &lt;/Setter.Value&gt;
          &lt;/Setter&gt;
      &lt;/Style&gt;
  </code></pre>
  
  <p>My cs:</p>
  
  <pre><code> namespace _3_Buttons
  {
      /// &lt;summary&gt;
      /// Interaction logic for MainWindow.xaml
      /// &lt;/summary&gt;
      public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
          }     
      }
  }
  </code></pre>