Smirti
Smirti

Reputation: 305

Not able to set resizing limit to grid splitter

I have two grids horizontally and i want to resize the first grid horizontally. so i used Grid Splitter like below,

    <Grid x:Name="grid">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition MinHeight="5"/>
        <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>
    <DataGrid ItemsSource="{Binding ItemsCollection}" AutoGenerateColumns="True"/>
    <GridSplitter Grid.Row="1" Height="3"   HorizontalAlignment="Stretch" Background="Red" />
    <DataGrid  Grid.Row="2" ItemsSource="{Binding ItemsCollection}" AutoGenerateColumns="True"/>
</Grid>

now i'm able to resize it . but i could resize it fully(to the header of a grid). i want to set limit to resizing. i dont want to hide entire grid by resizing. i want to show header and first row always.

Upvotes: 1

Views: 64

Answers (1)

maulik kansara
maulik kansara

Reputation: 1107

I have checked your scenario and Height="Auto" won't work. I have updated grid rows definition. please check below.

<Grid x:Name="grid">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" MinHeight="100"/>
            <RowDefinition Height="5"/>
            <RowDefinition Height="*" MinHeight="100"/>
        </Grid.RowDefinitions>
        <DataGrid ItemsSource="{Binding ItemsCollection}" AutoGenerateColumns="True"/>
        <GridSplitter Grid.Row="1" Height="3"   HorizontalAlignment="Stretch" Background="Red" />
        <DataGrid  Grid.Row="2" ItemsSource="{Binding ItemsCollection}" AutoGenerateColumns="True" />
    </Grid>

Upvotes: 2

Related Questions