I find myself nesting a lot of grids inside grids in WPF. I just found myself 3 Grids deep, and stopped to think: "Should I be doing this?" Is there some kind of performance cost? Is it unmaintainable? (Kind of like heavily nested if
s maybe.)
I guess the alternative is to have one grid, and use a whole lot of column spans.
(You may ignore the use of Events, I am aware commands are prob a better idea)
<Grid Name="grid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition/>
<RowDefinition Height="20"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Grid.Row="0" Grid.Column="0" VerticalAlignment="Top"
HorizontalAlignment="Left" Click="btnStart_Click"
Content="New Game"/>
<Button Grid.Row="0" Grid.Column="1" VerticalAlignment="Top"
HorizontalAlignment="Center" Click="btnRun_Click"
Content="Run"/>
<Button Grid.Row="0" Grid.Column="2" VerticalAlignment="Top"
HorizontalAlignment="Center" Click="btnUndo_Click"
Content="Undo"/>
<Button Grid.Row="0" Grid.Column="3" VerticalAlignment="Top"
HorizontalAlignment="Right" Click="btnStep_Click"
Content="Step"/>
<Grid Grid.Row="1" Grid.ColumnSpan="4">
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<board:BoardView x:Name="boardView" Grid.Row="0" Background="Firebrick"/>
<GridSplitter ResizeDirection="Rows" HorizontalAlignment="Stretch"
VerticalAlignment="Bottom" />
<TextBox Name="txtLog" Grid.Row="1"
Text="{Binding Path=GameLog.Log, Mode=TwoWay}"
VerticalScrollBarVisibility="Visible" FontFamily="Global Monospace"
AcceptsReturn="True" Height="260" VerticalAlignment="Stretch"/>
</Grid>
<CheckBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3"
Content="Use Algebraic Notation"
IsChecked="{Binding Path=UseAlgebraicNotation}"/>
</Grid>
<ContentControl Grid.Column="0"
Content="{Binding Path=Game.BlackPlayer}"
Margin="3"
/>
<ContentControl Grid.Column="3"
Content="{Binding Path=Game.WhitePlayer}"
Margin="3"
/>
</Grid>