在WPF中启用滚动条

41

我现在遇到的问题是,当我的WPF应用程序垂直缩小到一定程度时,它会隐藏窗口下方的任何内容。如何使用XAML让整个应用程序出现垂直滚动条,以便用户可以滚动查看其余内容?

1个回答

87

在你的窗口中放置一个 ScrollViewer:

<Window x:Class="WpfApplication2.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">

    <ScrollViewer >
        <!-- Window content here -->
    </ScrollViewer>
</Window>

当我使用ScrollViewer时,滚动条会出现,因为我正在使用动画将项目向下移动,当它到达窗口底部时,滚动条会显示,但我无法看到滚动条光标或通过鼠标进行滚动。 - Arsen Khachaturyan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接