Grid Splitter and MinWidth

I am trying to set a MinWidth for my columns.

MinWidth works correctly for Column 0 but not Column 2. The splitter just keeps dragging and I can get the Column to be less than the declared MinWidth The MinWidth seems to only take effect if the Column Width has a numeric value rather than Auto.... Is there a way to get that to work with Auto or just * ??

Any ideas?

    <!-- Content Area -->
    <Grid x:Name="ContentGrid"
          Grid.Row="2">
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="32" Width="260"/>
            <ColumnDefinition Width="8" />
            <ColumnDefinition MinWidth="100" Width="*" />
        </Grid.ColumnDefinitions>

        <!-- Navigation  -->
        <ItemsControl Name="NavigationRegion" 
                  Regions:RegionManager.RegionName="NavigationRegion"
                  Grid.Column="0">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
        <!-- Splitter -->
        <controls:GridSplitter x:Name="GridSplitter" 
                               Grid.Column="1" 
                               VerticalAlignment="Stretch" 
                               HorizontalAlignment="Center" 
                               Background="{StaticResource SplitterBackgroundColor}" 
                               Width="8" 
                               UseLayoutRounding="True" 
                               BorderThickness="1"     
                               BorderBrush="Black"  
                               Height="Auto"/>
        <!-- Form -->
        <ItemsControl x:Name="MainRegion"
                      Grid.Column="2" 
                      Regions:RegionManager.RegionName="MainRegion">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>


    </Grid>

Answers


The way I fixed this is to set a MaxWidth for Column 0. When SizeChanged fires I get the MaxWidth value for Column 0 based upon the current ActualWidth

So I removed my MinWidth from Column 2 as well. Here's the modifications:

<!-- Content Area -->
<Grid x:Name="ContentGrid"
      Grid.Row="2">
    <Grid.ColumnDefinitions>
        <ColumnDefinition MinWidth="32" Width="260"/>
        <ColumnDefinition Width="8" />
        <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>

...

Then the Event setting MaxWidth

this.SizeChanged += (s, e) =>
{
    double maxWidth = this.ActualWidth / 2.0;
    this.ContentGrid.ColumnDefinitions[0].MaxWidth = maxWidth;
}

Need Your Help

How do you refresh PreferenceActivity to show changes in the settings?

android settings refresh preferenceactivity immediate

Based on the following code, can you tell me how to refresh the PreferenceActivity window to show changes in the settings immediately? For example: the user taps the master chime toggle checkbox to...

adding element in array using array_push( ) in php

php arrays

adding element in array using array_push( ) in php

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.