title: WPF: Dynamic Form aligned by a <Grid>
body: <p>I'm building a GUI to edit various XML configuration files based on what values are allowed by their schema.  I need a way to display a label for each field in a left column, while displaying a control to edit that field on the right column.  If this list of fields weren't dynamic, I'd simply display them in a Grid with two columns.  But that doesn't seem so easy with a dynamic list of fields.</p>
  
  <p>The below example shows what I'd like to do, but because DataTemplate can only contain one child, this way won't work.  Anyone know of a good workaround that would make this dynamic form layout correctly?</p>
  
  <p>(To simplify the example, I'm using a Uniform grid.  I'd probably prefer an approach that drops a Grid in the ControlTemplate (so you can define the columns/rows) - but, I figured this approach got the point across)</p>
  
  <pre><code>        &lt;ItemsControl x:Name="FieldItemsCtrl"&gt;
              &lt;ItemsControl.ItemsPanel&gt;
                  &lt;ItemsPanelTemplate&gt;
                      &lt;UniformGrid Columns="2" /&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/ItemsControl.ItemsPanel&gt;
              &lt;ItemsControl.ItemTemplate&gt;
                  &lt;DataTemplate DataType="{x:Type local:EditableField}"&gt;
                      &lt;TextBlock Text="{Binding FieldName}" Foreground="{DynamicResource TextBrush}" /&gt;
                      &lt;TextBox Text="{Binding FieldValue}" /&gt;
                  &lt;/DataTemplate&gt;
              &lt;/ItemsControl.ItemTemplate&gt;
          &lt;/ItemsControl&gt;
  </code></pre>
  
  <p>Thanks!</p>