Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

For nested StackPanels scrollbar doesn't appear for inner stackpanel

$
0
0

Hi, I am creating dynamic controls and at runtime they are out of window even though the main window Grid has only one row and column each set to '*'
To help demonstrate, I created equivalent static design xaml here.
When all the expander controls are expanded, they go beyond the window.

I used scrollviewer on 'B':
a) on StackPanel spJobsB (containing gb'B' and Expander ) the horizontal scrollviewer appears across this entire row which is undesirable
b) on Expander expJobPrefixB (containing Stack Panel of group boxes B-1, B-2, ...) scrollviewer doesn't appear
c) on StackPanel spSubJobsB (containing group boxes B-1, B-2, ...) scrollviewer doesn't appear

I would like the Scrollbar to appear just for the items B-1,B-2,B-3, ... (not including B-)

Also, how I set the main expander label (Mon, Tue) with LightBlue backgroud and 'Stretch' but isn't stretching all the way to the Right

Can you please try the below code and help fix this?

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"><Grid><Grid.RowDefinitions><RowDefinition Height="*"></RowDefinition></Grid.RowDefinitions><Grid.ColumnDefinitions><ColumnDefinition Width="*"></ColumnDefinition></Grid.ColumnDefinitions><ScrollViewer VerticalScrollBarVisibility="Auto"><StackPanel Name="spCycles" Orientation="Vertical"><Expander Name="expCycle1"><Expander.Header><StackPanel Orientation="Horizontal"><Label FontWeight="Bold">This is cycle1</Label><Label Background="LightBlue" HorizontalAlignment="Stretch">Mon</Label></StackPanel></Expander.Header><Expander.Content><StackPanel Name="spSubCycles" Orientation="Vertical"><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="Auto"></ColumnDefinition></Grid.ColumnDefinitions><GroupBox Name="gbCycle1" Header="cycle1"></GroupBox></Grid><StackPanel Name="spBadJob" Orientation="Horizontal"><GroupBox Name="gbBadJob" Header="[bad job]"></GroupBox></StackPanel><StackPanel Name="spJobs" Orientation="Horizontal"><GroupBox Name="gbJobPrefix" Header="A-"></GroupBox><Expander Name="expJobPrefix" ExpandDirection="Right"><StackPanel Name="spSubJobs" Orientation="Horizontal"><GroupBox Header="A-1"></GroupBox><GroupBox Header="A-2"></GroupBox></StackPanel></Expander></StackPanel><StackPanel  Name="spJobsB" Orientation="Horizontal"><GroupBox Name="gbJobPrefixB" Header="B-"></GroupBox><Expander Name="expJobPrefixB" ExpandDirection="Right"><ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto"><StackPanel Name="spSubJobsB" Orientation="Horizontal"><GroupBox Header="B-1"></GroupBox><GroupBox Header="B-2"></GroupBox><GroupBox Header="B-3"></GroupBox><GroupBox Header="B-4"></GroupBox><GroupBox Header="B-5"></GroupBox><GroupBox Header="B-6"></GroupBox><GroupBox Header="B-7"></GroupBox><GroupBox Header="B-8"></GroupBox><GroupBox Header="B-9"></GroupBox><GroupBox Header="B-10"></GroupBox><GroupBox Header="B-11"></GroupBox></StackPanel></ScrollViewer></Expander></StackPanel></StackPanel></Expander.Content></Expander><Expander Name="expCycle2"><Expander.Header><StackPanel Orientation="Horizontal"><Label FontWeight="Bold">This is cycle2</Label><Label Background="LightBlue" HorizontalAlignment="Stretch">Tue</Label></StackPanel></Expander.Header><Expander.Content><StackPanel Orientation="Vertical"><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="Auto"></ColumnDefinition></Grid.ColumnDefinitions><GroupBox Header="cycle2"></GroupBox></Grid><StackPanel Orientation="Horizontal"><GroupBox Header="[bad job]"></GroupBox></StackPanel><StackPanel Orientation="Horizontal"><GroupBox Header="C-"></GroupBox><Expander ExpandDirection="Right"><StackPanel Orientation="Horizontal"><GroupBox Header="C-1"></GroupBox><GroupBox Header="C-2"></GroupBox></StackPanel></Expander></StackPanel><StackPanel  Orientation="Horizontal"><GroupBox Header="D-"></GroupBox><Expander ExpandDirection="Right"><StackPanel Orientation="Horizontal"><GroupBox Header="D-1"></GroupBox><GroupBox Header="D-2"></GroupBox><GroupBox Header="D-3"></GroupBox><GroupBox Header="D-4"></GroupBox><GroupBox Header="D-5"></GroupBox><GroupBox Header="D-6"></GroupBox><GroupBox Header="D-7"></GroupBox></StackPanel></Expander></StackPanel></StackPanel></Expander.Content></Expander></StackPanel></ScrollViewer></Grid></Window>

pic3
Thanks,

-srinivas y.



Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>