[BUG] GridSpliter does not respecting MinWidth / MinHeight

I have a window with a grid, 3 panels, and 2 grid spliters.  The right/bottom panels have MinWidth/MinHeight set to prevent the spliter from making them hidden, but it is not respecting those values and will make the panels smaller than their respective Min settings.



Answer this question

[BUG] GridSpliter does not respecting MinWidth / MinHeight

  • lordcornholio

    Looking at your code example above, the first think you'll want to do is not have a separate column for the GridSplitter. If you put it in an existing cell, it auto snaps to the right of that cell. You can also set it's properties so that it auto snaps to the bottom of the cell (ResideMode I believe)

    Also, setting MinWidth/MinHeight on the column definitions works for me. I'm sorry that I don't have access to a machine to test it out for you.

  • Matti Niskasaari

    Yes I know about it.  I have filed about 20 reports and received a response on 2 which requested information.  The last time I checked before PDC none had been closed, other than about 4 that were deferred to a later release.  So, the forum/news groups seem to do a better job of bringing issues to the attention of those actually doing the work.

    I really miss the old DEC problem tracking system.  Every bug report by a customer received a status update as is moved through the system.



  • tobimat80

    Apparently I can test it out:

    Here's the code I was mentioning you should use instead of three columns:

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Column="0" MinWidth="100">
            <TextBlock>Line one 1</TextBlock>
            <TextBlock>Line two 1</TextBlock>
        </StackPanel>
        <GridSplitter Grid.Column="0" ResizeDirection="Columns"/>
        <StackPanel Grid.Column="1" MinWidth="100">
            <TextBlock>Line one 2</TextBlock>
            <TextBlock>Line two 2</TextBlock>
        </StackPanel>
    </Grid>

    However, like  you said, this does not respect MinWidth. Changing the code to this gets your desired output:

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" MinWidth="100"/>
            <ColumnDefinition Width="*" MinWidth="100"/>
        </Grid.ColumnDefinitions>
        <StackPanel Grid.Column="0">
            <TextBlock>Line one 1</TextBlock>
            <TextBlock>Line two 1</TextBlock>
        </StackPanel>
        <GridSplitter Grid.Column="0" ResizeDirection="Columns"/>
        <StackPanel Grid.Column="1">
            <TextBlock>Line one 2</TextBlock>
            <TextBlock>Line two 2</TextBlock>
        </StackPanel>
    </Grid>

    But I agree, this is a bug. You're saying you've already submitted it

  • Tim Wright

    Michael-
      Can you post the simplified XAML that is causing the problem.  I have an idea what may be going on here, but need more information on how you our using Grid.

    Phillip

  • Schmidty6060

    The issue appears to be that columns do not respect the minimum width of the elements in them.  While this probably is more efficient it is not intuitive.  The layout engine should respect constraints on all the elements, not require duplicate specification of those constraints.  I would still say this is a bug in Grid.

    But, thanks for the pointer.  Setting MinWidth on the column works in my code as well.  The GridSplitter appears to be designed to support my 3 column case just fine.  There is a constant explicitly for the behavior I want, and this way I do not have to modify the elements in the ajoining columns to make room for the splitter.

    In my application the contents of the columns are dynamic, so i will need to update the column minimum width when changing the column contents.

  • Oli Green

    This sample exhibits the problem in XamlPad:

    <Page xmlns="http://schemas.microsoft.com/winfx/avalon/2005" xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005" >
      <Grid>
     <ColumnDefinition Width="*"/>
     <ColumnDefinition Width="Auto"/>
     <ColumnDefinition Width="*"/>
     <StackPanel Grid.Column="0" MinWidth="100">
      <TextBlock>Line one 1</TextBlock>
      <TextBlock>Line two 1</TextBlock>
     </StackPanel>
     <GridSplitter Grid.Column="1" ResizeDirection="Columns" ResizeBehavior="PreviousAndNext"/>
     <StackPanel Grid.Column="2" MinWidth="100">
      <TextBlock>Line one 2</TextBlock>
      <TextBlock>Line two 2</TextBlock>
     </StackPanel>
      </Grid>
    </Page>

  • Rajat Solanki

    Do you know about the Product Feedback Center   http://lab.msdn.microsoft.com/productfeedback/default.aspx It would be great if you logged your bug there.

    Thanks,
    Karsten


  • DavidAtPgMensys

    The issue you are seeing is not with Grid not respecting your minimum width setting.  The issue is with the GridSplitter control.  In order to get the behavior you are asking for with a GridSplitter you would need to derive a custom control from GridSplitter that would listen to the available size and stop layout on reaching the specified Min-width.  When GridSplitter was created it was intended for resizing columns without regard to the content of those columns.

    Phillip

  • [BUG] GridSpliter does not respecting MinWidth / MinHeight