Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Grid with 4 rows.

2nd row has a grid splitter

4th row has a status bar. I want to make sure that, no matter how the user moves the grid splitter - The status bar

Should remain fixed at bottom of the window.

What is happening right now is that, when user moves the gridsplitter too much downwards, the status bar is pushed out of the window.

what can I do to avoid this ?

This is my code.
XML
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="100"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*" MinHeight="100"></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>

        <GridSplitter Grid.Row="1" Height="10" HorizontalAlignment="Stretch" VerticalAlignment="Center"></GridSplitter>

        <StatusBar Grid.Row="3">
            <TextBox Text="Welcome"></TextBox>
        </StatusBar>

    </Grid>
</Window>
Posted
Updated 4-Sep-11 3:25am
v2

1 solution

Use two Grid's one with an inner Grid and the StatusBar and the inner grid contains the three rows

XML
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="100"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*" MinHeight="100"/>
        </Grid.RowDefinitions>
 
        <GridSplitter Grid.Row="2" Height="10" HorizontalAlignment="Stretch" VerticalAlignment="Top"/>
    </Grid>

 
    <StatusBar Grid.Row="1">
        <TextBox Text="Welcome"/>
    </StatusBar>
 
</Grid>
 
Share this answer
 
v2
Comments
AmitDey 4-Sep-11 9:38am    
Thanks Simon, That solves my main problem.

Another thing i am still facing is, the user can drag the gridsplitter outside the viewable window ( There is no way to pull it back ). Is there any way I can restrict to be inside the widnow.
Simon Bang Terkildsen 4-Sep-11 10:02am    
put your GridSplitter at the top of the third row, that should fix the problem
AmitDey 4-Sep-11 10:31am    
Thanks Simon, But I didn't get you

We have Set Grid.Row = 1 for grid splitter.
So it is in 2nd row.
ie. Above the 3rd row
Simon Bang Terkildsen 4-Sep-11 13:40pm    
When you set Grid.Row="1" then it's in the second row in the grid it is located assuming it has atleast 2 rows.
I've updated the answer to reflect what I'm suggesting

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900