wpf 使用 DockPanel 滚动内容

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21202872/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 10:32:55  来源:igfitidea点击:

Content scrolling with DockPanel

wpfxaml.net-4.0wpf-controls

提问by user2067120

I'm facing problem with scrolling content in Dock panel . My controls placed in 'DockPanel' as below

我在 Dock panel 中滚动内容时遇到问题。我的控件放置在“DockPanel”中,如下所示

<DockPanel>
<ScrollViewer>
 <StackPanel>
   <!-- Here controls are like Radiobutton,Lable ,CheckBox,Textblock are added dynamically in grid.-->
   </StackPanel>
</ScrollViewer>     

I'm using only vertical scrollbar, not need horizontal scrollbar, When I first time traverse through controls in 'DockPanel' by using tab ,Tab focus goes off the screen but panel is not scrolling down.

我只使用垂直滚动条,不需要水平滚动条,当我第一次使用 tab 遍历“DockPanel”中的控件时,Tab 焦点离开屏幕但面板没有向下滚动。

Please help me out I'm really stuck over here. Thanks in advance.

请帮帮我,我真的被困在这里了。提前致谢。

回答by Heena Patil

Add IsTabStop="True"in Scrollviewer:

添加IsTabStop="True"Scrollviewer

<DockPanel>
    <ScrollViewer IsTabStop="True" ScrollViewer.HorizontalScrollBarVisibility="Disabled">
        <StackPanel></StackPanel>                
    </ScrollViewer>
</DockPanel>