ScrollViewer in Avalonia DockPanel not scrolling to show all content when dynamically adding items.
Setup:
- Using Avalonia 11.2.2 with MVVM pattern
- Dialog with fixed height (700px) containing a DockPanel
- DockPanel structure:
- Header docked to Top (contains title + buttons)
- ScrollViewer fills remaining space (LastChildFill="True")
- ScrollViewer contains a StackPanel with form fields and an ItemsControl for dynamic items
When adding multiple items to the ItemsControl, the ScrollViewer doesn't scroll far enough to show the last items. Content appears cut off around 500px total height, even though the dialog is 700px tall and
there's more content below.
How do I ensure the ScrollViewer in a DockPanel properly scrolls through ALL content when items are dynamically added to an ItemsControl within a StackPanel?
Picture (Function 2 is missing):

2 Replies
dont use a stackpanel, use grid or some other controls
Solution
Updated ScrollViewer and StackPanel styling:
Changes:
- Removed Padding, VerticalScrollBarVisibility, and HorizontalScrollBarVisibility from ScrollViewer
- Changed spacing from 15 to 20
- Added Margin="15,15" to StackPanel (replaces ScrollViewer's padding)
This simplifies the ScrollViewer and moves styling responsibilities to the StackPanel itself.