title: Displaying data in WPF in the desired order
body: <p>I've the following xaml code in my C#/WPF app.</p>
  
  <p>I need to be able to display the contents of View1 after those textblocks and textboxes.Instead, the contents of View1 are now appearing after StackPanel contents.
  What am I missing here please?
  Thanks for your help.</p>
  
  <hr>
  
  <pre><code>&lt;Window
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:MainViewModel="clr-namespace:MyTool.ViewModel"
          xmlns:ViewModel="clr-namespace:MyTool.ViewModel.MyProducts"
          xmlns:View="clr-namespace:MyTool.View" x:Class="MyTool.MainWindow"
          xmlns:Views="clr-namespace:MyTool.View.MyProducts"
          xmlns:v="clr-namespace:MyTool.View.MyProducts"
          xmlns:vm="clr-namespace:MyTool.ViewModel.MyProducts"
          Title="{Binding DisplayName, Mode=OneWay}" ResizeMode="CanResize" WindowStartupLocation="CenterScreen"&gt;
      &lt;Window.DataContext&gt;
          &lt;MainViewModel:MyViewModel/&gt;
      &lt;/Window.DataContext&gt;
      &lt;Grid Margin="5"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
              &lt;RowDefinition Height="Auto"&gt;&lt;/RowDefinition&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;StackPanel Grid.Row="0"  HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal" Height="28" Width="auto" Margin="5,0,0,0"&gt;
  
          &lt;TextBlock TextWrapping="Wrap" Text="Security Type" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,0,5,0" Style="{DynamicResource DefaultTextBlockStyle}"/&gt;
              &lt;ComboBox Width="360" Margin="1,0" ItemsSource="{Binding MyProductTypes}" DisplayMemberPath="Code" SelectedValuePath="ID" SelectedItem="{Binding SelectedProductType, Mode=TwoWay}" TabIndex="0" /&gt;
  
  
  
  
  
              &lt;Button x:Name="btnSave" Content=" Save " Margin="25,0,5,0" Command="{Binding SaveCommand, Mode=OneWay}" TabIndex="31" /&gt;
  
              &lt;Button Content=" Clear " Command="{Binding ClearCommand, Mode=OneWay}" Margin="0,0,5,0" TabIndex="34"/&gt;
          &lt;/StackPanel&gt;
  
          &lt;Grid Margin="5" Grid.Row="1" &gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition Height="Auto"/&gt;
                  &lt;RowDefinition Height="Auto"/&gt;
                  &lt;RowDefinition Height="10"/&gt;
                  &lt;RowDefinition Height="Auto" MinHeight="24"/&gt;
                  &lt;RowDefinition Height="Auto"/&gt;
                  &lt;RowDefinition Height="Auto"/&gt;
                  &lt;RowDefinition Height="Auto"/&gt;
                  &lt;RowDefinition Height="Auto"/&gt;
                  &lt;RowDefinition Height="Auto"/&gt;
                  &lt;RowDefinition Height="Auto"/&gt;
                  &lt;RowDefinition Height="Auto"/&gt;
                  &lt;RowDefinition Height="Auto"/&gt;
                  &lt;RowDefinition Height="Auto"/&gt;
              &lt;/Grid.RowDefinitions&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="auto"/&gt;
                  &lt;ColumnDefinition Width="200"/&gt;
                  &lt;ColumnDefinition Width="23"/&gt;
                  &lt;ColumnDefinition Width="Auto"/&gt;
                  &lt;ColumnDefinition Width="14*"/&gt;
                  &lt;ColumnDefinition Width="Auto"/&gt;
                  &lt;ColumnDefinition Width="71*"/&gt;
              &lt;/Grid.ColumnDefinitions&gt;
         &lt;Grid Margin="5" Grid.Row="1" &gt;
  
              &lt;TextBlock  Grid.Column="6" HorizontalAlignment="Right" Grid.Row="0" TextWrapping="Wrap" VerticalAlignment="Bottom" Style="{DynamicResource SysdateMessageStyle}" Text="{Binding SystemDateMessage, Mode=OneWay}" Height="16" Width="0" /&gt;
              &lt;TextBlock  Grid.Column="1" HorizontalAlignment="Left" TextWrapping="Wrap" Text="T1" VerticalAlignment="Top" Grid.Row="1" Style="{DynamicResource HeadingStyle}" Grid.RowSpan="1" Margin="1,10,0,0" Height="23" Width="112"/&gt;
              &lt;TextBlock Grid.Column="1" HorizontalAlignment="Left" Margin="1,1,0,0" Grid.Row="3" TextWrapping="Wrap" VerticalAlignment="Top" Text="T2" Style="{DynamicResource DefaultTextBlockStyle}" Height="18" Width="61"/&gt;
              &lt;TextBlock Grid.Column="1" HorizontalAlignment="Left" Margin="1,1,0,0" Grid.Row="4" TextWrapping="Wrap" VerticalAlignment="Top" Text="T3" Style="{DynamicResource DefaultTextBlockStyle}" Height="18" Width="89"/&gt;
  
              &lt;TextBlock Grid.Column="1" HorizontalAlignment="Left" Margin="1,1,0,0" Grid.Row="5" TextWrapping="Wrap" VerticalAlignment="Top" Text="T4" Style="{DynamicResource DefaultTextBlockStyle}" Height="18" Width="103"/&gt;
              &lt;TextBlock Grid.Column="1" HorizontalAlignment="Left" Margin="1,1,0,0" Grid.Row="6" TextWrapping="Wrap" VerticalAlignment="Top" Text="T5" Style="{DynamicResource DefaultTextBlockStyle}" Height="18" Width="197"/&gt;
  
  
  
              &lt;TextBlock Grid.Column="1" HorizontalAlignment="Left" Margin="1,1,0,0" Grid.Row="7" TextWrapping="Wrap" VerticalAlignment="Top" Text="T6" Style="{DynamicResource DefaultTextBlockStyle}" Height="18" Width="103"/&gt;
  
              &lt;TextBox Name="txtTargetTicker1" Grid.Column="3" IsEnabled="{Binding EnableDealView}" HorizontalAlignment="Left" Height="23" Margin="1,1,0,0" Grid.Row="3" TextWrapping="Wrap" VerticalAlignment="Top" Width="155" Text="{Binding F1}" Style="{DynamicResource TargetTickerStyle}" TabIndex="2"/&gt;
  
              &lt;TextBox Name="txtTargetTicker" Grid.Column="3" IsEnabled="{Binding F2}" HorizontalAlignment="Left" Height="23" Margin="1,1,0,0" Grid.Row="4" TextWrapping="Wrap" VerticalAlignment="Top" Width="155" Text="{Binding F3}" Style="{DynamicResource TargetTickerStyle}" TabIndex="2"/&gt;
              &lt;TextBox Grid.Column="3" IsEnabled="{Binding F4}" HorizontalAlignment="Left" Height="23" Margin="1,21,0,0" Grid.Row="4" TextWrapping="Wrap" VerticalAlignment="Top" Width="155" Text="{Binding F5}" Style="{DynamicResource AcquirerTickerStyle}" TabIndex="3" Grid.RowSpan="2"/&gt;
  
              &lt;TextBox Grid.Column="3" IsEnabled="{Binding F6}" HorizontalAlignment="Left" Margin="1,1,0,0" Grid.Row="6" Width="155" Text="{Binding F7}" TabIndex="4"/&gt;
  
              &lt;StackPanel Grid.Column="3" IsEnabled="{Binding F8}" Grid.Row="7" HorizontalAlignment="Left" VerticalAlignment="Center" FlowDirection="LeftToRight" Orientation="Horizontal" Margin="0,3,0,0" Width="250" Height="22"&gt;
                  &lt;TextBox Grid.Column="2" IsEnabled="{Binding F9}" HorizontalAlignment="Left" Height="23" Margin="1,1,0,0" Grid.Row="5" TextWrapping="Wrap" VerticalAlignment="Top" Width="155" Style="{DynamicResource AcquirerTickerStyle}" TabIndex="3"/&gt;
              &lt;/StackPanel&gt;
  
              &lt;TextBlock Grid.Column="4" HorizontalAlignment="Left" Margin="1,1,0,0" Grid.Row="3" TextWrapping="Wrap" VerticalAlignment="Top" Style="{DynamicResource DefaultTextBlockStyle}" Height="18" Width="75" Grid.ColumnSpan="2"&gt;
              &lt;Run Text="Asset Currency"/&gt;
              &lt;Run Text="{Binding F10}"/&gt;
              &lt;/TextBlock&gt;
              &lt;TextBlock Grid.Column="4" HorizontalAlignment="Left" Margin="1,1,0,0" Grid.Row="4" TextWrapping="Wrap" VerticalAlignment="Top" Style="{DynamicResource DefaultTextBlockStyle}" Height="18" Width="87" Grid.ColumnSpan="2"&gt;
              &lt;Run Text="Manager"/&gt;
              &lt;Run Text="{Binding F11}"/&gt;
              &lt;/TextBlock&gt;
              &lt;TextBlock Grid.Column="4" HorizontalAlignment="Left" Margin="1,1,0,5" Grid.Row="5" TextWrapping="Wrap" Style="{DynamicResource DefaultTextBlockStyle}" Width="53" Grid.ColumnSpan="2"&gt;
              &lt;Run Text="Bid Value"/&gt;
              &lt;Run Text="{Binding F12}"/&gt;
              &lt;/TextBlock&gt;
  
              &lt;TextBlock Grid.Column="4" HorizontalAlignment="Left" Margin="1,1,0,0" Grid.Row="6" TextWrapping="Wrap" VerticalAlignment="Top" Text="Country of risk" Style="{DynamicResource DefaultTextBlockStyle}" Height="18" Width="120" Grid.ColumnSpan="2"/&gt;
  
  
          &lt;/Grid&gt;
              &lt;ContentPresenter Content="{Binding CurrentViewModel}"&gt;
                  &lt;ContentPresenter.Resources&gt;
                      &lt;DataTemplate DataType="{x:Type ViewModel:VM1}"&gt;
                          &lt;Views:View1/&gt;
                      &lt;/DataTemplate&gt;
                      &lt;DataTemplate DataType="{x:Type ViewModel:VM2}"&gt;
                          &lt;Views:View2/&gt;
                      &lt;/DataTemplate&gt;                  
                  &lt;/ContentPresenter.Resources&gt;
              &lt;/ContentPresenter&gt;
  
          &lt;/Grid&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>