将滚动条添加到框架 WPF
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14779109/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Adding a Scroll Bar to a Frame WPF
提问by charles082986
One of the pages I load into my frame is considerably larger than the frame itself. I have tried the instructions found at Frame on a resizable Window should show Scrollbarand my resulting xaml looks like this:
我加载到框架中的其中一个页面比框架本身大得多。我已经尝试了在可调整大小的窗口上的 Frame 中找到的指令应该显示 Scrollbar并且我生成的 xaml 如下所示:
<ScrollViewer>
<Frame
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.CanContentScroll="True"
Content=""
Name="mainFrame"
Grid.Row="1"
NavigationUIVisibility="Hidden"
Source="LoginPage.xaml"/>
</ScrollViewer>
Unfortunately, when I run this WPF application, the pages and/or frame are completely hidden. Removing the 2 ScrollViewer tags at the top and bottom of the code allow me to navigate again, but the problem page still has no scroll bars.
不幸的是,当我运行这个 WPF 应用程序时,页面和/或框架是完全隐藏的。删除代码顶部和底部的 2 个 ScrollViewer 标签,我可以再次导航,但问题页面仍然没有滚动条。
回答by Kevin DiTraglia
My first guess would be you are losing the grid row you want to be in via the nesting. Try this:
我的第一个猜测是您正在通过嵌套丢失您想要进入的网格行。尝试这个:
<ScrollViewer Grid.Row="1" >
<Frame
ScrollViewer.VerticalScrollBarVisibility="Visible"
ScrollViewer.CanContentScroll="True"
Content=""
Name="mainFrame"
NavigationUIVisibility="Hidden"
Source="LoginPage.xaml"/>
</ScrollViewer>

