I am looking for a less cumbersome way of laying out Key / Value pairs (e.g. Label saying "First Name" followed by a Label with the First Name) on a screen. If it were just a simple grouping I would throw it in a Grid and be done. However the layout 2 or 3 pairs, followed by some type of grouping container with 4 or 5 more pairs, followed by a different grouping container etc.
It feels very cumbersome to have to do something like:
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width=".2*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0" Content="Element ID:" HorizontalAlignment="Right" />
<Label Grid.Column="1" Grid.Row="0" Content="{Binding Path=ElementId}" HorizontalAlignment="Left" FontWeight="Bold" />
<Label Grid.Column="0" Grid.Row="1" Content="Element Description:" HorizontalAlignment="Right" />
<Label Grid.Column="1" Grid.Row="1" Content="{Binding Path=ElementDescription}" HorizontalAlignment="Left" FontWeight="Bold" />
</Grid>
Just to render out:
_______Element ID: ABC123
Element Description: Spiffy!
This is especially true when you have several sections like this.
UniformGrid won't let you fix one column so that the Label can be right aligned. I tried a combination of StackPanel and WrapPanel but you end up with almost as much overhead and a lot of margin fiddling.
Is there a better way to do this?