如何指定应使用哪个滚动查看器
考虑以下场景,表示左侧的项目列表和右侧的所选项目详细信息:(
<ScrollViewer Name="scroll1" >
<DockPanel>
<ScrollViewer Name="scroll2" DockPanel.Dock="Left" >
<Really Long List Box />
</ScrollViewer>
<Selected Item Details />
</DockPanel>
</ScrollViewer>
在上面的代码中,scroll2 始终禁用。)
在某些情况下,“所选项目详细信息”高度可能优于窗口高度。在这些情况下,应该启用scroll1。但大多数情况下并非如此。唯一大于窗口高度的控件是“Really Long List Box”,因此只应启用scroll2。
我知道最简单的方法是将scroll1放在“所选项目详细信息”的正上方,如下所示:
<ScrollViewer Name="scroll1" >
<Selected Item Details />
</ScrollViewer>
但这是一个内部框架,分为多个用户控件,而scroll1控件仅充当子控件的phaceholder,因此我无法删除它。
当“所选项目详细信息”适合窗口时,有什么方法可以仅启用滚动2?
Consider the following scenario representing a list of items on the left side and the selected item detail on the right side:
<ScrollViewer Name="scroll1" >
<DockPanel>
<ScrollViewer Name="scroll2" DockPanel.Dock="Left" >
<Really Long List Box />
</ScrollViewer>
<Selected Item Details />
</DockPanel>
</ScrollViewer>
(In the code above, scroll2 is always disable.)
In some cases "Selected Item Details" Height could be superior to the Window Height. In those cases the scroll1 should be enable. But in most cases it isn't. The only control bigger than the window height is the "Really Long List Box" so only scroll2 should be enable.
I know that the easiest way is to place scroll1 right above "Selected Item Details" like this:
<ScrollViewer Name="scroll1" >
<Selected Item Details />
</ScrollViewer>
But this is an in house framework that is divided in several UserControls and scroll1 control only serves as a phaceholder for child controls so I can't remove it.
Is there any way to enable only scroll2 when "Selected Item Details" fits on the window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您没有显式设置滚动查看器的高度和宽度,那么它将采用父元素的高度和宽度。在这种情况下,scroll2 看起来像是采用了停靠面板的高度和宽度,这就是为什么scroll2 滚动未启用的原因。尝试设置scroll2的高度和宽度,你应该能够滚动它。
If you don't explicitly set the height and width of a scrollviewer then it will take the height and width of the parent element. In this case, it looks like scroll2 is taking the height and width of the dock panel which is why scroll2 scrolling isn't enabled. Try setting the height and width of scroll2 and you should be able to scroll it.