我有一个网格。该网格包含一个滚动查看器,该滚动查看器包含一个列表框,其项目是扩展器。当展开扩展器直到它们超过 UserControl 的垂直可用高度时,滚动查看器的滚动条会正确显示。当我再次折叠扩展器时,滚动查看器的滚动条保持不变!它不会像预期的那样再次缩小或消失。
我已经尝试了一些不同的网格行设置(“自动”、“*”)和不同的垂直对齐设置(顶部、拉伸、...)
折叠扩展器后,如何设法使滚动查看器再次缩小?
<UserControl x:Class="Expanderin_Scroller.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable="d"
d:DesignWidth="440"
d:DesignHeight="300">
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ScrollViewer x:Name="ScrToolbox"
Grid.Row="1"
VerticalAlignment="Top">
<ListBox x:Name="Toolbox">
<telerik:RadExpander Header="Expander 1">
<StackPanel>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
</StackPanel>
</telerik:RadExpander>
<telerik:RadExpander Header="Expander 2">
<StackPanel>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
</StackPanel>
</telerik:RadExpander>
<telerik:RadExpander Header="Expander 3">
<StackPanel>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
</StackPanel>
</telerik:RadExpander>
<telerik:RadExpander Header="Expander 4">
<StackPanel>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
<TextBlock>Hello</TextBlock>
</StackPanel>
</telerik:RadExpander>
</ListBox>
</ScrollViewer>
</Grid>
</UserControl>