Bender
Bender

Reputation: 523

How to resize the height of a TabControl?

As the title, I was wondering if it was possible to set some property type: CanUserResize = true; I'm working on a very responsive and actually come up well, but now I want to make sure that the TabControl is somehow possible to be able to increase the height manually, as happens exactly grabbing the edges of the window of 'Window OS or OS X OS' dragging them up or down. On the net I found nothing, perhaps in WPF is not yet implemented a similar mode .... There would be a similar road for this purpose should achieve?

Upvotes: 1

Views: 163

Answers (1)

almulo
almulo

Reputation: 4978

You must use a GridSplitter to achieve what you're trying to do.

A GridSplitter is just one special Control that can be placed inside a Grid, and allows the user to grab it and move it up and down (or right or left, depending on whether the splitter is horizontal or vertical) to resize the rows and columns of the Grid.

In your case, you could do something like this:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" MinHeight="200" MaxHeight="500" />
        <RowDefinition Height="5" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <TabControl x:Name="myTabControl"
                Grid.Row="0" />
    <GridSplitter Grid.Row="1"
                  HorizontalAlignment="Stretch"
                  VerticalAlignment="Stretch" />
</Grid>

You can style the GridSplitter any way you want, and use horizontal and vertical splitters at the same time if you like, or even several horizontal or vertical splitters.

EDIT: Generally, the GridSplitter figures out automatically whether it's horizontal or vertical, but you can specify it manually using the ResizeDirection property (with values Auto, Columns or Rows).

EDIT 2: I've added a MinHeight and a MaxHeight values to the first ColumnDefinition to exemplify how you can prevent the GridSplitter from going past some sizes.

Upvotes: 2

Related Questions