tags:

views:

1321

answers:

1
+1  A: 

You're on the right path. However, you need to use some column definitions, and your row definitions are a bit wonky. You're using a bunch of different layout panels embedded in each other, which is affecting the Viewbox built-in resizing. You can accomplish this exact same layout with a single, simple, 5x5 grid (no stackpanels).

I have demonstrated this in the following XAML:

<Window x:Class="TestWpfApplication.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TestWpfApplication"
Title="Window1">
<Window.Resources>
 <Style TargetType="{x:Type Label}" x:Key="{x:Type Label}">
  <Setter Property="HorizontalAlignment" Value="Center"/>
  <Setter Property="VerticalAlignment" Value="Center"/>
 </Style>
</Window.Resources>

<Grid>
 <Grid.RowDefinitions>
  <RowDefinition/>
  <RowDefinition/>
  <RowDefinition/>
  <RowDefinition/>
  <RowDefinition/>
 </Grid.RowDefinitions>
 <Grid.ColumnDefinitions>
  <ColumnDefinition/>
  <ColumnDefinition/>
  <ColumnDefinition/>
  <ColumnDefinition/>
  <ColumnDefinition/>
 </Grid.ColumnDefinitions>

 <ListBox Grid.RowSpan="5" Grid.Column="0">
  <ListBoxItem>a</ListBoxItem>
  <ListBoxItem>b</ListBoxItem>
  <ListBoxItem>c</ListBoxItem>
 </ListBox>

 <Label Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="4">Title</Label>

 <Label Grid.Row="1" Grid.Column="1">A</Label>
 <Label Grid.Row="2" Grid.Column="1">B</Label>
 <Label Grid.Row="3" Grid.Column="1">C</Label>
 <Label Grid.Row="4" Grid.Column="1">D</Label>

 <Viewbox Grid.Row="1" Grid.Column="2">
  <Label>1</Label>
 </Viewbox>
 <Viewbox Grid.Row="2" Grid.Column="2">
  <Label>2</Label>
 </Viewbox>
 <Viewbox Grid.Row="3" Grid.Column="2">
  <Label>3</Label>
 </Viewbox>
 <Viewbox Grid.Row="4" Grid.Column="2">
  <Label>4</Label>
 </Viewbox>

 <Viewbox Grid.Row="1" Grid.Column="3">
  <Label>5</Label>
 </Viewbox>
 <Viewbox Grid.Row="2" Grid.Column="3">
  <Label>6</Label>
 </Viewbox>
 <Viewbox Grid.Row="3" Grid.Column="3">
  <Label>7</Label>
 </Viewbox>
 <Viewbox Grid.Row="4" Grid.Column="3">
  <Label>8</Label>
 </Viewbox>

 <Label Grid.Row="1" Grid.Column="4">E</Label>
 <Label Grid.Row="2" Grid.Column="4">F</Label>
 <Label Grid.Row="3" Grid.Column="4">G</Label>
 <Label Grid.Row="4" Grid.Column="4">H</Label>
</Grid>

Charlie