I have the below XAML. The issue that I cannot seem to solve is that I have a scroll viewer that is wrapping around a grid full of views (with a fixed height) but cannot get the scroll bars to scroll on content longer than the window size.
I want the user control to fill the full hight of the window but also be scrollable when the amount of grid controls length is greater than the window size. But if I do not set the height of the scroll viewer manually then I will never get the scrollable scrollbar (manually set in the example).
I have looked at other examples on the site but cannot come across a valid answer (including this link).
XAML:
<UserControl d:DesignWidth="300" d:DataContext="{d:DesignInstance ViewModels:EntityViewModel}">
<StackPanel>
<Label Content=“text” />
<ScrollViewer Height="450" Width="250" VerticalScrollBarVisibility="auto">
<Grid>
<ItemsControl ItemsSource="{Binding Entities}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<local:EntityView DataContext="{Binding}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</ScrollViewer>
</StackPanel>
</UserControl>
Edit:
I'm adding an additional example which can be easily recreated. The need is to be able to have the scroll view to be scrollable with the dock panel (can be a grid) has more content than can fit on the screen of which the user control is inserted (which means I can't have a fixed size on the scroll viewer).
<Window Title="MainWindow" Height="200" Width="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<Label Content="title"/>
<ScrollViewer>
<DockPanel>
<Label DockPanel.Dock="Top" Content="title" HorizontalContentAlignment="Center" />
<Label DockPanel.Dock="Top" Content="title" HorizontalContentAlignment="Center" />
<Label DockPanel.Dock="Top" Content="title" HorizontalContentAlignment="Center" />
<Label DockPanel.Dock="Top" Content="title" HorizontalContentAlignment="Center" />
<Label DockPanel.Dock="Top" Content="title" HorizontalContentAlignment="Center" />
<Label DockPanel.Dock="Top" Content="title" HorizontalContentAlignment="Center" />
<Label DockPanel.Dock="Top" Content="title" HorizontalContentAlignment="Center" />
</DockPanel>
</ScrollViewer>
</StackPanel>
</Grid>
</Window>