如何指定应使用哪个滚动查看器

发布于 2024-10-31 06:03:02 字数 791 浏览 2 评论 0原文

考虑以下场景,表示左侧的项目列表和右侧的所选项目详细信息:(

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独孤求败 2024-11-07 06:03:02

如果您没有显式设置滚动查看器的高度和宽度,那么它将采用父元素的高度和宽度。在这种情况下,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文