tags:

views:

91

answers:

2

I've got two sizing issue regarding a Window I've got. The basic layout is like this

<Window MaxHeight="{DynamicResource {x:Static SystemParameters.VirtualScreenHeight}}"
        MaxWidth="{DynamicResource {x:Static SystemParameters.VirtualScreenWidth}}" 
        >
    <StackPanel>
        <DockPanel LastChildFill="False">
            <StackPanel DockPanel.Dock="Left"
                        Orientation="Horizontal">
                <!--Some buttons-->
            </StackPanel>
            <StackPanel DockPanel.Dock="Right"
                        Orientation="Horizontal">
                <!--Some buttons-->
            </StackPanel>
        </DockPanel>
        <ScrollViewer>
            <WrapPanel x:Name="Container">
            </WrapPanel>
        </ScrollViewer>
    </StackPanel>
</Window>

1) How do I made the Window not get smaller horizontally than the DockPanel's width?

2) How do I make the ScrollViewer be restricted to the limits of the Window? It is sizing itself to its contents, extending past the bounds of the Window.
It sort of used to work when I had

<Window><ScrollViewer/></Window>

, but I really don't want the DockPanel inside the scroller. In the current form, it is even forcing the Window to break its MaxHeight.

+1  A: 

I would recommend you to use Grid with * Lenght instead of DockPanel and StackPanel.

Jobi Joy
+1  A: 

Just get rid of those StackPanels. Replace them with Grids and you should be good. The layout logic of the StackPanel is such that it will give children as much room in a certain direction (perpendicular to the StackPanels orientation) as they ask for. That's why you're seeing the odd layout issues.

HTH, Kent

Kent Boogaart