Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8163955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:11:23+00:00 2026-06-06T19:11:23+00:00

I have a Grid with 2 columns separated by a GridSplitter using the following

  • 0

I have a Grid with 2 columns separated by a GridSplitter using the following XAML code :

<Grid>
    <Grid.ColumnDefinitions>
    <ColumnDefinition Width="100" MinWidth="20" />
    <ColumnDefinition Width="10" />
    <ColumnDefinition Width="*" MinWidth="100" />
    </Grid.ColumnDefinitions>

    <Rectangle Fill="Blue" />
    <GridSplitter Grid.Column="1" Background="LightGray" HorizontalAlignment="Stretch" />
    <Rectangle Fill="Yellow" Grid.Column="2" />
</Grid>

Problem : The MinWidth of the Column on the right is ignored

  • I definitely need the first column Width to be “100px” when page loads, so It cannot be * sized.
  • I do not want to set a MaxWidth on the first column

*I know that has been adressed before but it always suggest to set column size to * or set a maxWidth on the first column… I don’t want that.


Found a solution, but its UGLY! :p, anybody has a cleaner way to achieve what I want… CODELESS (if possible)?

private void Grid_SizeChanged(object sender, SizeChangedEventArgs e)
{
   var g = (Grid)sender;

   Double maxW = e.NewSize.Width - g.ColumnDefinitions[2].MinWidth - g.ColumnDefinitions[1].ActualWidth;
   g.ColumnDefinitions[0].MaxWidth = maxW;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:11:25+00:00Added an answer on June 6, 2026 at 7:11 pm

    The basic problem is that a grid splitter works by adjusting the width of the left column only and assumes the right column will star-size to fit the remaining space.

    That means the problem you are trying to solve is actually “how do I limit the max width of the left column so that the right column does not get too small?”. This is basically what your code sample is doing.

    If you want a more portable solution, that you can implement in XAML, create a Silverlight behavior that can be applied to a grid (as shown below). It will attach to the parent grid’s SizeChanged event and do pretty much exactly what your code snippet does, but being a behavior you can drag and drop them in Blend or attach them in XAML.

    Here is a sample behavior I threw together for you as an example (based on your own code):

    MinWidthSplitterBehavior.cs

    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Interactivity;
    
    namespace GridSplitterMinWidth
    {
        public class MinWidthSplitterBehavior : Behavior<Grid>
        {
            public Grid ParentGrid { get; set; }
    
            protected override void OnAttached()
            {
                base.OnAttached();
                ParentGrid = this.AssociatedObject as Grid;
                ParentGrid.SizeChanged += parent_SizeChanged;
            }
    
            void parent_SizeChanged(object sender, SizeChangedEventArgs e)
            {
                if (ParentGrid.ColumnDefinitions.Count == 3)
                {
                    Double maxW = e.NewSize.Width - ParentGrid.ColumnDefinitions[2].MinWidth -
                                  ParentGrid.ColumnDefinitions[1].ActualWidth;
                    ParentGrid.ColumnDefinitions[0].MaxWidth = maxW;
                }
            }
    
            protected override void OnDetaching()
            {
                base.OnDetaching();
                if (ParentGrid != null)
                {
                    ParentGrid.SizeChanged -= parent_SizeChanged;
                }
            }
        }
    }
    

    and use it like this:

    <UserControl x:Class="GridSplitterMinWidthApp.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:GridSplitterMinWidth="clr-namespace:GridSplitterMinWidth"
        xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        xmlns:Controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
    
        <Grid x:Name="LayoutRoot" Background="White">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100" MinWidth="20" />
                    <ColumnDefinition Width="10" />
                    <ColumnDefinition Width="*" MinWidth="100" />
                </Grid.ColumnDefinitions>
                <interactivity:Interaction.Behaviors>
                    <GridSplitterMinWidth:MinWidthSplitterBehavior/>
                </interactivity:Interaction.Behaviors>
                <Rectangle Fill="Blue" />
                <Controls:GridSplitter Grid.Column="1" Background="LightGray" HorizontalAlignment="Stretch">
                </Controls:GridSplitter>
                <Rectangle Fill="Yellow" Grid.Column="2" />
            </Grid>
        </Grid>
    </UserControl>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a grid view and I add columns to it by code: //Retrieve
I have grid something like this: Ext.define('Exp.view.dashboard.Tv', { extend: 'Ext.grid.Panel', initComponent: function() { this.columns
I have a grid where first 2 columns are bound with ForeignKey (Category and
I have a grid view that has two simple columns, a report number and
I have a grid in my GWT application there are columns and rows which
I have a grid which has 4 bands and the columns in band[3] are
I have a Grid which contains an Image in one of its columns. The
I have a weird grid with different height columns. By this I mean, column
I have a datagrid in C#.net I have made some columns in grid editable.
I have a grid with 4 buttons...1 row, 4 columns. I am looking for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.