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 does one implement a job queue in .NET?

c# .net .net-4.0 jobs

I have a Windows service that processes jobs. A job in this service is a sequence of actions, such as:

Using jQuery to extract value from a row

javascript jquery html

I'm building a tic-tac-toe game with javascript. The issue is when I am checking to see if there are any winners on the board after each move.

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.