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 3210834
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:37:40+00:00 2026-05-17T14:37:40+00:00

I have two grids with three rows each. The first and last row of

  • 0

I have two grids with three rows each. The first and last row of each grid has a fixed height while the middle rows have auto height and share their height using SharedSizeGroup.

First, the content of the right grid determines the height of the size group. When the content of the right grid shrinks so that the content of the left grid determines the height of the size group, the overall size of the left grid is not adjusted correctly.

See the following sample app. Click the increase button to increase the size of the textblock in the right grid. The size of the left grid changes accordingly. Now decrease the size. When the textblock becomes smaller than the textblock in the left grid, the total size of the left grid doesn’t shrink. Is this a bug or am i missing something?

<StackPanel Orientation="Horizontal" Grid.IsSharedSizeScope="True">
    <StackPanel Orientation="Vertical" Width="100">
        <Grid Background="Green">
            <Grid.RowDefinitions>
                <RowDefinition Height="15" />
                <RowDefinition SharedSizeGroup="Group1" />
                <RowDefinition Height="15" />
            </Grid.RowDefinitions>
            <TextBlock Background="Blue" Grid.Row="0" />
            <TextBlock Background="Red" Grid.Row="1" Name="textBlock1" Height="100" />
            <TextBlock Background="Blue" Grid.Row="2" />
        </Grid>
        <TextBlock Text="{Binding Path=ActualHeight, ElementName=grid1}" />
    </StackPanel>
    <StackPanel Orientation="Vertical" Width="100">
        <Grid Background="Green">
            <Grid.RowDefinitions>
                <RowDefinition Height="15" />
                <RowDefinition SharedSizeGroup="Group1" />
                <RowDefinition Height="15" />
            </Grid.RowDefinitions>
            <TextBlock Background="Blue" Grid.Row="0" />
            <TextBlock Background="Red" Grid.Row="1" Name="textBlock2" Height="150" />
            <TextBlock Background="Blue" Grid.Row="2" />
        </Grid>
        <TextBlock Text="{Binding Path=ActualHeight, ElementName=grid2}" />
    </StackPanel>
    <Button Height="24" Click="Button_Click_1" VerticalAlignment="Top">Increase</Button>
    <Button Height="24" Click="Button_Click_2" VerticalAlignment="Top">Decrease</Button>
</StackPanel>

private void Button_Click_1(object sender, RoutedEventArgs e)
{
    textBlock2.Height += 30;
}

private void Button_Click_2(object sender, RoutedEventArgs e)
{
    textBlock2.Height -= 30;
}
  • 1 1 Answer
  • 1 View
  • 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-05-17T14:37:40+00:00Added an answer on May 17, 2026 at 2:37 pm

    The rows are staying the same height – the size of the second TextBlock is changing, while the size of the first TextBlock remains 100.

    To demonstrate this, make the following changes:

    • Add ShowGridLines="True" to each of your Grids
    • Change your named TextBlocks to show their ActualHeight as their text:

          <TextBlock Background="Red" Grid.Row="1" Name="textBlock2" Height="150"
                     Text="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}"/>
      

    You will see that the SharedSizeGroup row will be the maximum ActualHeight of the two TextBlocks.

    Update: A Short Project To Show What’s Happening
    I’ve created a quick-n-dirty project to show what’s happening. It turns out that when the right grid gets smaller than the original size, the left grid does an Arrange but not a Measure. I am not sure I understand this completely – I have posted a follow-up question with this same solution.

    Here is the solution that I created, based on your original. It simply wraps the basic grid in a custom class that spews out info (via event) when Measure and Arrange are called. In the main window, I just put that info into a list box.

    InfoGrid and InfoGridEventArgs classes

    using System.Windows;
    using System.Windows.Controls;
    namespace GridMeasureExample
    {
        class InfoGrid : Grid
        {
            protected override Size ArrangeOverride(Size arrangeSize)
            {
                CallReportInfoEvent("Arrange");
                return base.ArrangeOverride(arrangeSize);
            }
            protected override Size MeasureOverride(Size constraint)
            {
                CallReportInfoEvent("Measure");
                return base.MeasureOverride(constraint);
            }
            public event EventHandler<InfoGridEventArgs> ReportInfo;
            private void CallReportInfoEvent(string message)
            {
                if (ReportInfo != null)
                    ReportInfo(this, new InfoGridEventArgs(message));
            }
        }
        public class InfoGridEventArgs : EventArgs
        {
            private InfoGridEventArgs()
            {
            }
            public InfoGridEventArgs(string message)
            {
                this.TimeStamp = DateTime.Now;
                this.Message = message;
            }
            public DateTime TimeStamp
            {
                get;
                private set;
            }
            public String Message
            {
                get;
                private set;
            }
        }
    }
    

    Main Window XAML

    <Window x:Class="GridMeasureExample.Window1"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"    
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:GridMeasureExample"
            Title="SharedSizeGroup" Height="500" Width="500">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
    
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
    
            <StackPanel Grid.Column="0" 
                        Grid.Row="0"
                        Orientation="Horizontal" 
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Grid.IsSharedSizeScope="True">
    
                <StackPanel Orientation="Vertical" Width="100">
                    <local:InfoGrid x:Name="grid1" Background="Green" ShowGridLines="True">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="15" />
                            <RowDefinition SharedSizeGroup="Group1" />
                            <RowDefinition Height="15" />
                        </Grid.RowDefinitions>
                        <TextBlock Background="Blue" Grid.Row="0" Text="Row 0"/>
                        <TextBlock Background="Red" Grid.Row="1" Name="textBlock1" Height="100"
                               Text="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}"/>
                        <TextBlock Background="Blue" Grid.Row="2" Text="Row 2" />
                    </local:InfoGrid>
                    <TextBlock Text="{Binding Path=ActualHeight, ElementName=grid1}" />
                </StackPanel>
    
                <StackPanel Orientation="Vertical" Width="100">
                    <local:InfoGrid x:Name="grid2" Background="Yellow" ShowGridLines="True">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="15" />
                            <RowDefinition SharedSizeGroup="Group1" />
                            <RowDefinition Height="15" />
                        </Grid.RowDefinitions>
                        <TextBlock Background="Orange" Grid.Row="0" Text="Row 0" />
                        <TextBlock Background="Purple" Grid.Row="1" Name="textBlock2" Height="150"
                               Text="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}"/>
                        <TextBlock Background="Orange" Grid.Row="2" Text="Row 2" />
                    </local:InfoGrid>
                    <TextBlock Text="{Binding Path=ActualHeight, ElementName=grid2}" />
                </StackPanel>
    
            </StackPanel>
    
            <ListBox x:Name="lstInfo"
                     Grid.Column="1"
                     Grid.Row="0"
                     Margin="10,0,0,0"
                     HorizontalAlignment="Stretch"
                     VerticalAlignment="Stretch" />
    
            <UniformGrid Grid.Column="0"
                         Grid.Row="1"
                         Grid.ColumnSpan="2"
                         Columns="2"
                         HorizontalAlignment="Center"
                         Margin="5">
                <Button x:Name="btnIncrease" Margin="4,0">Increase</Button>
                <Button x:Name="btnDecrease" Margin="4,0">Decrease</Button>
            </UniformGrid>
    
        </Grid>
    
    </Window>
    

    Main Window Constructor (only code in code-behind)

    public Window1()
    {
    InitializeComponent();

        btnIncrease.Click += (s, e) => 
            {
                lstInfo.Items.Add(String.Format("{0} Increase Button Pressed", DateTime.Now.ToString("HH:mm:ss.ffff")));
                textBlock2.Height += 30;
            };
        btnDecrease.Click += (s, e) =>
            {
                lstInfo.Items.Add(String.Format("{0} Decrease Button Pressed", DateTime.Now.ToString("HH:mm:ss.ffff")));
                if (textBlock2.ActualHeight >= 30)
                    textBlock2.Height -= 30;
            };
    
        grid1.ReportInfo += (s, e) => lstInfo.Items.Add(String.Format("{0} Left Grid: {1}", e.TimeStamp.ToString("HH:mm:ss.ffff"), e.Message));
        grid2.ReportInfo += (s, e) => lstInfo.Items.Add(String.Format("{0} Right Grid: {1}", e.TimeStamp.ToString("HH:mm:ss.ffff"), e.Message));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three nested grids where first two of them has background images with
I have two grid views containing 12 and 24 rows resp. Each row contains
I have two grids with same number of rows ( also same height). Both
I have a grid view that has two simple columns, a report number and
Hi I have a grid of around 30 cells each with two images, a
I have a grid with two rows plus a grid splitter. I want the
I have two grids, thay both have one store. I need to show everything
In .net objects like DataTable when you have two grids(Master and Detail) and add
I have two grid, one with auto-generated fields and the other not. how can
i have two int array of images , i have implemented it in grid

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.