title: 'Transposing' controls in rows and columns in a WPF Grid
body: <p>I have a wrappanel that acts as a container for a group of controls defined as </p>
  
  <pre><code>&lt;WrapPanel Orientation="Horizontal"&gt;
    &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
        &lt;RowDefinition  /&gt;
        &lt;RowDefinition   /&gt;
        &lt;RowDefinition   /&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Label Grid.Row="0"&gt;test1&lt;/Label&gt;
      &lt;ComboBox Grid.Row="1" MinWidth="60"&gt;&lt;/ComboBox&gt;
      &lt;ComboBox Grid.Row="2" MinWidth="60"&gt;&lt;/ComboBox&gt;
    &lt;/Grid&gt;
    &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
        &lt;RowDefinition  /&gt;
        &lt;RowDefinition   /&gt;
        &lt;RowDefinition   /&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Label Grid.Row="0"&gt;test1&lt;/Label&gt;
      &lt;TextBox Grid.Row="1" MinWidth="60"&gt;&lt;/TextBox&gt;
      &lt;TextBox Grid.Row="2" MinWidth="60"&gt;&lt;/TextBox&gt;
    &lt;/Grid&gt;
    &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
        &lt;RowDefinition  /&gt;
        &lt;RowDefinition   /&gt;
        &lt;RowDefinition   /&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Label Grid.Row="0"&gt;test1&lt;/Label&gt;
      &lt;ComboBox Grid.Row="1" MinWidth="60"&gt;&lt;/ComboBox&gt;
      &lt;ComboBox Grid.Row="2" MinWidth="60"&gt;&lt;/ComboBox&gt;
    &lt;/Grid&gt;           
  &lt;/WrapPanel&gt;
  </code></pre>
  
  <p>So basically it wraps multiple grids that have 3 rows each, and every cell in the grid has a control.
  I want the user to have the ability to 'transpose' this layout so that the wrappanel now has a vertical orientation and the grid is now a 3 column grid. So if done manually the xaml would look like</p>
  
  <pre><code>&lt;WrapPanel Orientation="Vertical"&gt;
    &lt;Grid&gt;
      &lt;Grid.ColumnDefinitions&gt;
        &lt;ColumnDefinition  /&gt;
        &lt;ColumnDefinition  /&gt;
        &lt;ColumnDefinition  /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Label Grid.Column="0"&gt;test1&lt;/Label&gt;
      &lt;ComboBox Grid.Column="1" MinWidth="60"&gt;&lt;/ComboBox&gt;
      &lt;ComboBox Grid.Column="2" MinWidth="60"&gt;&lt;/ComboBox&gt;
    &lt;/Grid&gt;
    &lt;Grid&gt;
      &lt;Grid.ColumnDefinitions&gt;
        &lt;ColumnDefinition  /&gt;
        &lt;ColumnDefinition  /&gt;
        &lt;ColumnDefinition  /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Label Grid.Column="0"&gt;test1&lt;/Label&gt;
      &lt;TextBox Grid.Column="1" MinWidth="60"&gt;&lt;/TextBox&gt;
      &lt;TextBox Grid.Column="2" MinWidth="60"&gt;&lt;/TextBox&gt;
    &lt;/Grid&gt;
    &lt;Grid&gt;
      &lt;Grid.ColumnDefinitions&gt;
        &lt;ColumnDefinition  /&gt;
        &lt;ColumnDefinition  /&gt;
        &lt;ColumnDefinition  /&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Label Grid.Column="0"&gt;test1&lt;/Label&gt;
      &lt;ComboBox Grid.Column="1" MinWidth="60"&gt;&lt;/ComboBox&gt;
      &lt;ComboBox Grid.Column="2" MinWidth="60"&gt;&lt;/ComboBox&gt;
    &lt;/Grid&gt;           
  &lt;/WrapPanel&gt;
  </code></pre>
  
  <ol>
  <li>Whats the best way to achieve this?</li>
  <li>Is there any way to do this and avoid codebehind?</li>
  </ol>