GridSplitter resize next
Asked Answered
P

1

0

It seems I can't use GridSplitter to resize next item. Here is xaml:

<Grid>
    <!-- this works -->
    <Grid Background="Gray" HorizontalAlignment="Left">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
        </Grid.ColumnDefinitions>
        <GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" />
    </Grid>
    <!-- this doesn't -->
    <Grid Background="Gray" HorizontalAlignment="Right">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="100" />
        </Grid.ColumnDefinitions>
        <GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" />
    </Grid>
</Grid>

and demo:

Notice what left Grid can be resized, while right one has some issues. You can try given xaml yourself to see what I mean.

What should I do to make next item resizing working?

Puffer answered 28/4, 2016 at 12:48 Comment(0)
E
1

I made it work by changing ColumnDefinition Width

<Grid>
    <Grid Background="Gray" HorizontalAlignment="Left">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" />
    </Grid>
    <Grid Background="Gray" HorizontalAlignment="Right">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="100" />
        </Grid.ColumnDefinitions>
        <GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" />
    </Grid>
</Grid>

and another variant I like more:

<Grid>
    <Grid Background="Gray">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="100" />
        </Grid.ColumnDefinitions>

        <GridSplitter Grid.Column="1" Width="10" ResizeBehavior="PreviousAndNext" />

        <Border Grid.Column="2" Background="Gold"/>

        <GridSplitter Grid.Column="3" Width="10" ResizeBehavior="PreviousAndNext" />
    </Grid>
</Grid>
Etom answered 28/4, 2016 at 13:15 Comment(2)
Do you have explanation why * is working and auto is also working but only in one direction? My problem is to have optional content in non-resizable column, this is why it must be auto. Not sure if it will work with *, give me a minute.Puffer
@Sinatr, i can only guess that is inner logic of splitter. Since grids have Left and Right horizontal alignment, * becomes an autoEtom

© 2022 - 2025 — McMap. All rights reserved.