The problem with the ability to scroll and expand.
Scrollable-expandable-controls: controls that can stretch as content grows and display scrollbars when their size is limited.
The problem occurs when they are inside another scroll control. Child-friendly scroll controllers will continue to expand and will be counted on the external scrollable scroll controls.
if you indicate that the problem with the maximum width or height will be resolved, but you will need to know the size in front, and you do not have this privilege if you want the dynamic application to work well with all the different screen sizes.
in order to achieve the desired behavior, we need a panel between them to allow our children (with the ability to scroll-expandable-control) to grow, asking them to provide the minimum required size, and then provide them with the maximum size provided by the parent, without displaying scroll bars, currently time there is no such panel.
Here is one that I developed to provide this feature:
class LimitChild : System.Windows.Controls.Panel { public LimitChild() { } protected override Size MeasureOverride(System.Windows.Size availableSize) { System.Diagnostics.Debug.Assert(InternalChildren.Count == 1); System.Windows.UIElement child = InternalChildren[0]; Size panelDesiredSize = new Size();
and then inside your xaml encapsulate your scrollable-extensible control in it.
<l:LimitChild Grid.Row="1"> <TextBox VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" MinHeight="200" AcceptsReturn="True">Test</TextBox> </l:LimitChild>
Ashi
source share