wpfgridsplitter

Increase WPF GridSplitter mouse grabbing threshold


Is it possible to increase the distance from a grid splitter from which the user can grab it?

My splitter is only 1px in width. I would like to be able to grab the splitter from a greater distance.

As it is now i must point the mouse on the exact 1px line to grab it.

And the splitter must still be 1px in width


Solution

  • You can change the actual size of the GridSplitter while keeping it looking like it's smaller. This will give you a 7 pixel width area to grab it while showing at 1 pixel:

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition/>
            <ColumnDefinition Width="1"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <GridSplitter Grid.Column="1"
                      Margin="-3,0"
                      BorderThickness="3,0"
                      BorderBrush="Transparent"
                      HorizontalAlignment="Stretch" />
    </Grid>
    

    The example is using the method of giving the splitter its own column but the same principle applies if it's Left or Right aligned in a shared column.