如何使我的GroupBox / StackPanel可滚动?

时间:2015-05-22 12:54:29

标签: c# wpf xaml

<GroupBox x:Name="groupBox1" Header="Item1" HorizontalAlignment="Left" Margin="10,94,0,0" VerticalAlignment="Top" Height="179" Width="280">
            <StackPanel>
                <RadioButton GroupName="County" Content="County1" IsChecked="True"/>
                <RadioButton GroupName="County" Content="County2" />
                <RadioButton GroupName="County" Content="County3" />
                <RadioButton GroupName="County" Content="County4" />
                <RadioButton GroupName="County" Content="County5" />
                <RadioButton GroupName="County" Content="County6" />

我的列表很长,所以我只显示前6个

我的UI显示了RadioButton但它继续超越GroupBox。那么我可以使StackPanel或GroupBox可滚动吗?

我尝试将此添加到我的StackPanel但没有工作

<StackPanel ScrollViewer.VerticalScrollBarVisibility="Auto" CanVerticallyScroll="True">

1 个答案:

答案 0 :(得分:3)

是的,你可以。

ScrollViewer周围包裹StackPanel

<ScrollViewer>
   <StackPanel>
      ...
   </StackPanel>
</ScrollViewer>