The scrollviewer below does not work. I tried everything I could find on this site and beyond: embedding the scrollviewer in an Grid, embedding the ScrollViewer's children in a grid, embedding the Scrollviewer in a StackPanel with fixed height, setting/binding the height of the scrollviewer, all to no avail... Who shows me the way back to sanity??
Mind, the XAML below is just to show how the window is structured. I removed all the data.
<Window>
<Window.Resources>
<DataTemplate x:Key="ColoringLabels">
</DataTemplate>
</Window.Resources>
<DockPanel>
<StatusBar DockPanel.Dock="Top">
<StatusBarItem>
</StatusBarItem>
</StatusBar>
<StackPanel Orientation="Vertical">
<TextBox/>
<Button>Hello World!</Button>
<ScrollViewer>
<StackPanel Orientation="Vertical">
<Label>Hola Mundo!</Label>
<ListBox ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox ItemsSource="{StaticResource ColoringLabels}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox Source="{Binding}"ItemTemplate="{StaticResource ColoringLabels}"/>
</StackPanel>
</ScrollViewer>
<TextBlock/>
</StackPanel>
</DockPanel>
</Window>
EDIT:
I solved it by changing the XAML to:
<Window>
<Window.Resources>
<DataTemplate x:Key="ColoringLabels">
</DataTemplate>
</Window.Resources>
<DockPanel>
<StatusBar DockPanel.Dock="Top">
<StatusBarItem>
</StatusBarItem>
</StatusBar>
<ScrollViewer>
<StackPanel Orientation="Vertical">
<TextBox />
<Button>Hello World!</Button>
<StackPanel Orientation="Vertical">
<Label>Hola Mundo!</Label>
<ListBox ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<ListBox ItemsSource="{StaticResource ColoringLabels}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox Source="{Binding}"ItemTemplate="{StaticResource ColoringLabels}"/>
</StackPanel>
<TextBlock/>
</StackPanel>
</ScrollViewer>
</DockPanel>
</Window>
Why it is working now??? Perhaps because the ScrollViewer now gets to fill the LastChild position of the DockPanel???