title: WPF. How to add text under image in c#
body: <p>I have image which I set behind code and now I have to set 3 texts under the picture also behind code, maybe somenoe knoe how to make it? 
  my xaml:</p>
  
  <pre><code> ...&lt;Style x:Key="imageStyle" TargetType="{x:Type Image}"&gt;
                      &lt;Setter Property="Height" Value="152px"/&gt;
                      &lt;Setter Property="Width" Value="762"/&gt;
                  &lt;/Style&gt;
  &lt;/windows.Resources&gt;
  &lt;Grid&gt;
           &lt;StackPanel x:Name="StackStyle" Background="#FFFFFF" Margin="30,98,250,150"&gt;...
  </code></pre>
  
  <p>My xaml.cs is: </p>
  
  <pre><code> public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
  
              this.Loaded += OnLoaded;
          }
  
          private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
          {
              Style imgStyle = (Style)Resources["imageStyle"];
              var imag = new Image();
              imag.Style = imgStyle;
              string path = System.AppDomain.CurrentDomain.BaseDirectory + "../../ico.choose-coupon.png";
              imag.Source = new BitmapImage(new Uri(path));
  
  
              StackStyle.Children.Add(imag);
  
          }
      }
  </code></pre>
  
  <p>do not forget that this is one image, and these text have to be under Gray field.</p>
  
  <p><strong>UPDATE:</strong>
  I get what I want, thats the code:
  xaml:</p>
  
  <pre><code>&lt;Viewbox Stretch="Fill"&gt;
          &lt;Grid&gt;
          &lt;StackPanel Orientation="Vertical" x:Name="myStackPanel"  Background="#FFFFFF" Height="560" Width="968"  HorizontalAlignment="Center" &gt;
              &lt;Label  Style="{StaticResource Label}" &gt;&lt;/Label&gt;
  
          &lt;/StackPanel&gt;    
      &lt;/Grid&gt;
  &lt;/Viewbox&gt;
  </code></pre>
  
  <p>xaml.cs:</p>
  
  <pre><code>public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
  
              this.Loaded += OnLoaded;
          }
  
          private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
          {
  
  
              string path = System.AppDomain.CurrentDomain.BaseDirectory + "../../ico.choose-coupon.png";
  
              Style imgStyle = (Style)Resources["imageStyle"];
  
              var imag = new Image();
              imag.Style = imgStyle;
              imag.Source = new BitmapImage(new Uri(path));
  
              myStackPanel.Children.Add(imag);
  
              Style textStyle = (Style) Resources["textStyle"];
              var text1 = new TextBlock();
              var text2 = new TextBlock();
              var text3 = new TextBlock();
  
  
  
              text1.Style = textStyle;
              text2.Style = textStyle;
              text3.Style = textStyle;
              text1.Text = "% coupon";
              text2.Text = "Tara receipt";
              text3.Text = "Value coupon";
              text1.Margin = new Thickness(135,22,0,0);
              text2.Margin = new Thickness(210, 22, 0, 0);
              text3.Margin = new Thickness(188, 22, 0, 0);
  
              var TextPanel = new StackPanel();
              TextPanel.Orientation = Orientation.Horizontal;
  
              TextPanel.Children.Add(text1);
              TextPanel.Children.Add(text2);
              TextPanel.Children.Add(text3);
  
              myStackPanel.Children.Add(TextPanel);
  
          }
      }
  </code></pre>