Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gridsplitter not showing

I am new to WPF. I declared my Grid as so:

<Grid.ColumnDefinitions>
    <ColumnDefinition Width="Auto"></ColumnDefinition>
    <ColumnDefinition Width="5"></ColumnDefinition>
    <ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
     <Grid.RowDefinitions>
         <RowDefinition Height="*"></RowDefinition>
         <RowDefinition Height="*"></RowDefinition>
         <RowDefinition Height="*"></RowDefinition>
     </Grid.RowDefinitions>
</Grid>

I basically want that 3rd column of width 5 to be the GridSplitter and to be resizeable for the left and right columns. So I have this code for the splitter:

<GridSplitter Grid.Column="1" Grid.RowSpan="3" ResizeDirection="Columns" Height="Auto"
              VerticalAlignment="Stretch" HorizontalAlignment="Center"
              Margin="0" Background="Black"/>

I do not see the GridSplitter in the column. Did I set it up right? Thanks.

like image 593
Crystal Avatar asked Aug 18 '11 15:08

Crystal


1 Answers

You have the GridSplitter centering in it's column, but it has no width defined. So you are effectively centering it with a width of zero. It also looks like you have two Grids, where you'd need one.

Seems like you want something like this:

<Grid>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"></ColumnDefinition>
        <ColumnDefinition Width="Auto"></ColumnDefinition>
        <ColumnDefinition Width="*"></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="*"></RowDefinition>
        <RowDefinition Height="*"></RowDefinition>
        <RowDefinition Height="*"></RowDefinition>
    </Grid.RowDefinitions>

    <GridSplitter Grid.Column="1" Grid.RowSpan="3" ResizeDirection="Columns" Height="Auto"
         Width="5" VerticalAlignment="Stretch" Margin="0" Background="Black"/>

</Grid>

If you need the nested Grid, then you may need to duplicate the Column definitions.

like image 52
CodeNaked Avatar answered Sep 27 '22 15:09

CodeNaked