Child of Vertical ResizingPanel doesn't display when within Auto sized row

Nov 4, 2009 at 4:57 PM

As I said in my other post, thanks for the library!

I'm trying to place a DockingManager in an Auto-sized Grid row.  Here is the Xaml:

<Window x:Class="WPFExperiments.AvalonDockTest5MeasuringIssues"
    Title="AvalonDockTest5MeasuringIssues" Height="300" Width="300">
    <Grid Background="Yellow">
            <RowDefinition Height="Auto" />
            <ad:ResizingPanel Orientation="Vertical">
                    <ad:DockableContent Title="Test Header">
                        <TextBlock Background="Green" Foreground="White">Test</TextBlock>

When you launch that application, the contents don't display.  The reason appears to be some code within ResizingPanel::MeasureOverride.  This is in an if statement near the top of the function intended to deal with Infinite measurements:

//Thx to TMx
else if (availableSize.Height == double.PositiveInfinity &&
    Orientation == Orientation.Vertical)
    Size newAvailSize = new Size();
    foreach (FrameworkElement child in visibleChildren)
        newAvailSize.Width = Math.Max(child.DesiredSize.Width, newAvailSize.Width);
        newAvailSize.Height += child.DesiredSize.Height;
    availableSize = newAvailSize;

 In the Horizontal case, the corresponding highlighted line calls child.Measure with availableSize rather than newAvailSize.  That appears to be the correct approach.  newAvailSize is initially 0,0, which results in a child.DesiredSize of 0,0.  That prevents the child from ever being displayed.  Changing the line in the code I copied above to use availableSize appears to achieve the desired results (the content is displayed correctly).


David Cater