Is nesting grids a good idea? 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 ifs 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)



&lt;Grid Name="grid"&gt;
&lt;Grid.ColumnDefinitions&gt;
    &lt;ColumnDefinition Width="*"/&gt;
    &lt;ColumnDefinition Width="*"/&gt;
    &lt;ColumnDefinition Width="*"/&gt;
&lt;/Grid.ColumnDefinitions&gt;

&lt;Grid Grid.Column="1"&gt;
    &lt;Grid.RowDefinitions&gt;
        &lt;RowDefinition Height="20"/&gt;
        &lt;RowDefinition/&gt;
        &lt;RowDefinition Height="20"/&gt;
    &lt;/Grid.RowDefinitions&gt;
    &lt;Grid.ColumnDefinitions&gt;
        &lt;ColumnDefinition/&gt;
        &lt;ColumnDefinition/&gt;
        &lt;ColumnDefinition/&gt;
        &lt;ColumnDefinition/&gt;
    &lt;/Grid.ColumnDefinitions&gt;

    &lt;Button Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" 
        HorizontalAlignment="Left" Click="btnStart_Click" 
        Content="New Game"/&gt;
    &lt;Button Grid.Row="0" Grid.Column="1" VerticalAlignment="Top" 
        HorizontalAlignment="Center" Click="btnRun_Click" 
        Content="Run"/&gt;
    &lt;Button Grid.Row="0" Grid.Column="2" VerticalAlignment="Top" 
        HorizontalAlignment="Center" Click="btnUndo_Click" 
        Content="Undo"/&gt;
    &lt;Button Grid.Row="0" Grid.Column="3" VerticalAlignment="Top" 
        HorizontalAlignment="Right" Click="btnStep_Click" 
        Content="Step"/&gt;

    &lt;Grid Grid.Row="1" Grid.ColumnSpan="4"&gt;
        &lt;Grid.RowDefinitions&gt;
            &lt;RowDefinition/&gt;
            &lt;RowDefinition/&gt;
        &lt;/Grid.RowDefinitions&gt;
        &lt;board:BoardView x:Name="boardView" Grid.Row="0"  Background="Firebrick"/&gt;
        &lt;GridSplitter  ResizeDirection="Rows" HorizontalAlignment="Stretch" 
            VerticalAlignment="Bottom" /&gt;
        &lt;TextBox Name="txtLog" Grid.Row="1" 
            Text="{Binding Path=GameLog.Log, Mode=TwoWay}"
            VerticalScrollBarVisibility="Visible" FontFamily="Global Monospace" 
            AcceptsReturn="True" Height="260" VerticalAlignment="Stretch"/&gt;

    &lt;/Grid&gt;

    &lt;CheckBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3"  
        Content="Use Algebraic Notation" 
        IsChecked="{Binding Path=UseAlgebraicNotation}"/&gt;

&lt;/Grid&gt;

&lt;ContentControl Grid.Column="0" 
                Content="{Binding Path=Game.BlackPlayer}"
                Margin="3"
                /&gt;

&lt;ContentControl Grid.Column="3" 
                Content="{Binding Path=Game.WhitePlayer}"
                Margin="3"
                /&gt;

&lt;/Grid&gt;
It's better to use nested grids that are easy to read, than complex spanning.  I try to avoid spanning in most scenarios, unless it's just 1 simple span.  But when in doubt, nest the grids, because that way future layout changes won't break everything where as spanning is directly tied to the number of columns you have.

A great example of this is headers and footers, you wouldn't want them to not fill the width of an app,