ScrollViewer: add a switch to prevent content from growing outside the visible area when it does not have to
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
At present, if a `ScrollViewer` has a descendent element that is also a scrollable control, said descendent will always grow to its maximum size rather than taking advantage of the fact that it is _also_ capable of scrolling. It would be nice if there was a setting on `ScrollViewer` to clamp such descendents down to the visible area when possible, only showing scrollbars when the content can shrink no further (e.g., the area is smaller than a minimum size assigned to the contents).
Example (project attached):
[testscrollviewer.zip](https://github.com/dotnet/wpf/files/12611815/testscrollviewer.zip)
How I'd like it to look:

How it looks:

---
I know of ways to _mostly_ accomplish this currently with hacks like binding the max height/width of `FooControl` to a parent (e.g., `ScrollContentPresenter` or `ScrollViewer` itself), but this isn't perfect, and some cases contain foot guns.
Contributor guide
Assessment
This issue has not been assessed yet.