ContentControl3D awareness of size

Mar 23, 2009 at 4:50 AM
I was about to do a small DataGrid sample using your ContentControl3D in a DataGridTemplateColumn then found an issue with sizing.  Apparently the content size in your ContentControl3D is not respected by layout.  For example, if you had a Grid such as this:



        <RowDefinition Height="Auto"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>

TextBlock Text="WPF DataGrid with Thriple.ContentControl3D Sample" />

    <thriple:ContentControl3D Grid.Row="1">
            <TextBlock Text="Testing" />



The expectation is that the measure for row one will yield enough space for the content in ContentControl3D (just like a general ContentControl).  However, the space is not given. 

I'm not as familiar with Viewport2DVisual3D and Viewport3D to recommend a solution or workaround at this time but I'll take a look at the wpf source code first thing tomorrow.  Or maybe you already know the limitations or solution but I'll give it a look anyway just in case.

Mar 23, 2009 at 12:43 PM
Layout of elements within a ContentControl3D is not quite as straightforward as one would hope.  You nailed it on the head when you pointed out that the problem lies in Viewport2DVisual3D.  Everything shown in one of those elements is displayed as if it is being stretched in a Viewbox.  I assume that this must mean that it does not ask its child elements to measure themselves in the same way that a normal element would, which would lead to the layout issue you've pointed out (unknown desired size?).  I'm not totally clear on exactly what causes this behavior, but I have worked around it by setting Width/Height or MaxWidth/MaxHeight on the elements in ContentControl3D, or on the ContentControl3D itself.

If you find a better solution, or if this is something that can be addressed in ContentControl3D, please let me know.