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

  • Home
  • SEARCH
  • 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 3244554
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:33:54+00:00 2026-05-17T18:33:54+00:00

There seems to be a bit of an issue with two grids containing elements

  • 0

There seems to be a bit of an issue with two grids containing elements specified in a certain way, and the SharedSizeGroup.

This question is in response to an earlier question from user D.H. I attempted to answer. Forgive the length, but it helps to demonstrate the problem visually.

His original question asked why two grids with a SharedSizeGroup didn’t resize to the same height when certain conditions were met (resizing a TextBlock in the right-side grid). I took his example and expanded it, because I suspected that it had to do with the Measure/Arrange cycle.

It turns out that it does, in fact, have to do with Measure and Arrange. Actually, it has to do with not doing a Measure. I feel that this may be at least an issue, if not a bug, but would like to have an explanation of the behavior.

Here is a quick overview of what happens (garish colors for demo purposes only).

Start Up
Both grids have three rows, each containing a TextBlock. The middle row is of SharedSizeGroup. The text of the middle row is bound to the ActualHeight of its TextBlock, with the initial Height property hard-coded to the values you see. The numbers below the grids represent the ActualHeight of that grid. Note that the BackgroundColor of the left grid is Green.

Startup

Increasing the Right-Side TextBlock
When the right-side grid is increased in size, you can see that both grids resize to the new height, due to the SharedSizeGroup. The column at the right reflects the Measure and Arrange calls of the grids.

Increased In Size

Decreasing the Right-Side TextBlock But Still Greater Than Left-Side TextBlock
When the right-side grid is decreased in size, but still larger than the size of the hard-coded TextBlock of the left side, you can see that both grids again resize to the new height, due to the SharedSizeGroup. The column at the right reflects the Measure and Arrange calls of the grids.

Decreased to Minimum Size

Decreasing the Right-Side TextBlock Less Than Size of Left-Side TextBlock
When the right-side grid is decreased in size, less than the size of the hard-coded TextBlock of the left side, you can see that the left-side grid does not decrease to the “proper” size, as evidenced by seeing the Green background of the grid at the bottom, and the fact that the size of the grid is 150, not 130.

If you look at the info on the right, you will notice that the Left grid did an Arrange, but did not do a Measure.

Decreased Past Size


Here is the example code to duplicate the issue.

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));
}
  • 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-05-17T18:33:55+00:00Added an answer on May 17, 2026 at 6:33 pm

    According to Microsoft, it’s a bug.

    This appears to be a bug in WPF, and
    Microsoft is aware of it and
    investigating a solution.

    If you need help with a workaround,
    please contact Microsoft Support at

    http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone

    You can also submit bug feedback for
    WPF regarding this issue at…

    http://connect.microsoft.com/VisualStudio

    I’ve submitted this as a bug on the Connect site.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary Using Windows GDI to convert 24-bit color to indexed color, it seems GDI
Hmm... Title is a bit of a mouthful, but I'm really not sure which
I'm a bit stuck trying to figure out how to design an Oracle query,
My company has a VB6 application using Crystal Reports 7 which a client has
I've developed a JS-heavy site using the Mootools library and have hit a bump
I use TeamCity which in turn invokes msbuild (.NET 4). I have a strange
DISCLAIMER: At my place of work we are aware that, as none of us
I have a window with the following properties set int he .rc file: STYLE
I've just finished installing Hadoop 0.20.2 under Cygwin on Windows 7 with Eclipse Helios

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.