title: How to convert below xaml Programmatically?
body: <p>I want format Header like in image (INWARD in First Line, Gross Wt., Pure Wt. &amp; Qty. in Second Line). I can achieve same with following code in XAML, but how can I do this Programmatically?</p>
  
  <p>XAML:</p>
  
  <pre><code>   &lt;dg:DataGrid&gt;
          &lt;dg:DataGridTemplateColumn Width="210"&gt;
              &lt;dg:DataGridTemplateColumn.HeaderTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Grid&gt;
                          &lt;Grid.RowDefinitions&gt;
                              &lt;RowDefinition /&gt;
                              &lt;RowDefinition /&gt;
                          &lt;/Grid.RowDefinitions&gt;
                          &lt;TextBlock Grid.Row="0" 
                                     Text="INWARD" 
                                     TextAlignment="Center"&gt;
                          &lt;/TextBlock&gt;
                          &lt;StackPanel Grid.Row="1" Orientation="Horizontal"&gt;
                              &lt;TextBlock Width="80"
                                         Text="Gross Weight"
                                         TextAlignment="Right"
                                         Margin="0,0,2,0"&gt;
                              &lt;/TextBlock&gt;
                              &lt;TextBlock Width="80"
                                         Text="Pure Weight" 
                                         TextAlignment="Right"
                                         Margin="0,0,0,0"&gt;
                              &lt;/TextBlock&gt;
                              &lt;TextBlock Width="40"
                                         Text="Quantity"
                                         TextAlignment="Right"
                                         Margin="2,0,0,0"&gt;
                              &lt;/TextBlock&gt;
                          &lt;/StackPanel&gt;
                      &lt;/Grid&gt;
                  &lt;/DataTemplate&gt;
              &lt;/dg:DataGridTemplateColumn.HeaderTemplate&gt;
              &lt;dg:DataGridTemplateColumn.CellTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;StackPanel Orientation="Horizontal" &gt;
                          &lt;TextBlock Style="{DynamicResource grdCellCurrencyData}" 
                                                         Width="80"
                                                         Margin="0,0,2,0"&gt;
                              &lt;TextBlock.Text&gt; 
                                  &lt;MultiBinding Converter="{StaticResource CurrencyConverter}" ConverterParameter="True"&gt;
                                      &lt;Binding Path="INGrossWeight" Mode="OneWay" /&gt;
                                      &lt;Binding Path="BaseUOMNoofDecimals" Mode="OneWay" /&gt;
                                  &lt;/MultiBinding&gt; 
                              &lt;/TextBlock.Text&gt;
                          &lt;/TextBlock&gt;
                          &lt;TextBlock Style="{DynamicResource grdCellCurrencyData}"
                                                             Width="80"
                                                             Margin="0,0,0 0"&gt;
                              &lt;TextBlock.Text&gt; 
                                  &lt;MultiBinding Converter="{StaticResource CurrencyConverter}" ConverterParameter="True"&gt;
                                      &lt;Binding Path="INPureWeight" Mode="OneWay" /&gt;
                                      &lt;Binding Path="BaseUOMNoofDecimals" Mode="OneWay" /&gt;
                                  &lt;/MultiBinding&gt; 
                              &lt;/TextBlock.Text&gt;
                          &lt;/TextBlock&gt;
                          &lt;TextBlock Style="{DynamicResource grdCellCurrencyData}"
                                     Width="40"
                                     Text="{Binding Path=INQuantity, Mode=OneWay}" Margin="2,0,0,0"&gt;
                          &lt;/TextBlock&gt;
                      &lt;/StackPanel&gt;
                  &lt;/DataTemplate&gt;
              &lt;/dg:DataGridTemplateColumn.CellTemplate&gt;
          &lt;/dg:DataGridTemplateColumn&gt;
      &lt;/dg:DataGrid&gt;
  </code></pre>
  
  <p>In above code if you see in <code>DataGridTemplateColumn</code>, I have taken grid inside and split header in two rows. Same way I want to do programmatically from code behind. can anybody help?</p>