我有一个包含 ScrollViewer 的 UserControl。
<UserControl>
<ScrollViewer Name="ScrollContainerScroller"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Hidden">
<ListBox Name="MyItemsListBox" ItemsSource="{Binding MyItems}"/>
</ScrollViewer>
</UserControl>
在堆栈面板中使用此 UserControl 时,不会显示 ScrollViewer 的滚动条。
<Border>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <!-- top -->
<RowDefinition Height="*"/> <!-- content -->
<RowDefinition Height="Auto"/> <!-- bottom -->
</Grid.RowDefinitions>
<StackPanel Grid.Row="1" VerticalAlignment="Top">
<Grid Name="ContentButtons" Height="20">
<Button Name="MinimizeContent"/>
<Button Name="MaximizeContent"/>
</Grid>
<ContentControl Name="MyContent"/>
</StackPanel>
<!--
<ContentControl Name="MyContent" Grid.Row="1" VerticalAlignment="Top"/>
-->
<Grid Name="MyBottomControls" Grid.Row="2" VerticalAlignment="Bottom">
<Button Name="Delete" HorizontalAlignment="Left" Style="{StaticResource DeleteButtonStyle}"/>
<Button Name="Close" HorizontalAlignment="Center" Style="{StaticResource CloseButtonStyle}"/>
<Button Name="Hide" HorizontalAlignment="Right" Style="{StaticResource HideButtonStyle}"/>
</Grid>
<!-- shows up at last so the Grid can place it at the very top it in the Z axis -->
<ContentControl Name="MyTop" Grid.Row="0" VerticalAlignment="Top"/>
</Grid>
</Border>
当我删除包装堆栈面板时,滚动查看器会正确显示。
为了使滚动条也可以与包装 MyContent-contentcontrol 的附加堆栈面板一起使用,我需要做些什么?