Silverlight ListBox:如何查明用户当前是否正在拖动滚动条滑块?

发布于 2024-11-09 17:57:28 字数 955 浏览 0 评论 0原文

场景:我有一个 ListBox,其中包含 Silverlight Toolkit 中的 WrapPanel 作为 ItemsPanel:

<ListBox x:Name="listBoxFaelle">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <toolkit:WrapPanel />
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.Template>
        <ControlTemplate>
            <Grid>
                <ScrollViewer>
                    <ItemsPresenter />
                </ScrollViewer>
            </Grid>
        </ControlTemplate>
    </ListBox.Template>
</ListBox>

此 ListBox 每 60 秒自动填充一次 RIA 服务调用的结果。当应用程序等待 LoadOperation 完成时,它会显示作为 Silverlight 业务应用程序模板一部分的标准 BusyIndi​​cator。

只要用户在计时器事件触发时不拖动列表框的滚动条滑块,就可以正常工作。

问题:如果用户在显示 BusyIndi​​cator 时拖动滚动条滑块,则此后滚动条将不再工作。即使释放鼠标左键,鼠标指针仍然被捕获到滑块上。我认为发生这种情况是因为 BusyIndi​​cator 在拖动滑块时暂时夺走了滑块的焦点。

问题:有没有办法知道ListBox的滚动条滑块当前是否被推动?

Scenario: I have a ListBox, containing a WrapPanel from the Silverlight Toolkit as ItemsPanel:

<ListBox x:Name="listBoxFaelle">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <toolkit:WrapPanel />
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>
    <ListBox.Template>
        <ControlTemplate>
            <Grid>
                <ScrollViewer>
                    <ItemsPresenter />
                </ScrollViewer>
            </Grid>
        </ControlTemplate>
    </ListBox.Template>
</ListBox>

This ListBox gets populated automatically with the results of a RIA service call every 60 seconds. While the application is waiting for the LoadOperation to complete, it displays the standard BusyIndicator that is part of the Silverlight Business Application template.

This works fine as long as the user is not dragging the scrollbar slider of the ListBox when the Timer Event fires.

Problem: If the user is dragging the scrollbar slider when the BusyIndicator is being displayed, the scrollbar doesn’t work anymore, afterwards. It looks like the mouse pointer remains captured to the slider even if the left mouse button is released. I assume this happens because the BusyIndicator temporarily takes away the focus from the slider while it is being dragged.

Question: Is there a way to find out if the scrollbar slider of the ListBox is currently being pushed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

白云不回头 2024-11-16 17:57:28

据我所知,没有状态/属性可以确定滑块是否被推动。

也就是说,您可以尝试通过处理MouseLeftButtonDown 和 Up 事件,但您可能还需要根据您的场景考虑其他事件(鼠标滚轮?)

MouseLeftButtonUp 当鼠标(或手写笔)位于 UIElement 上方(或 UIElement 保持鼠标捕获时)释放鼠标左键(或从平板电脑上移开手写笔笔尖)时发生。 (继承自UIElement。)

也可以通过使用 ReleaseMouseCapture

同样,这取决于您希望从用户的角度发生的情况:跳过加载数据(这是我更喜欢的,因为我不喜欢滚动时内容发生变化)或重置列表框并滚动到顶部(我认为丑陋)

As far as I know there is no status/property to find out if the slider is being pushed.

That said you could try to keep track of it yourself by handling MouseLeftButtonDown and Up events but you might have to consider other events as well depending on your scenario (mouse wheel?)

MouseLeftButtonUp Occurs when the left mouse button is released (or the tip of the stylus is removed from the tablet) while the mouse (or the stylus) is over a UIElement (or while a UIElement holds mouse capture). (Inherited from UIElement.)

It might also be possible to solve this the other way around by releasing the MouseCapture (if that is causing the problem) by using ReleaseMouseCapture

Again, it depends on what you want to happen from the user's point of view: skip the loading of the data (this is what I would prefer because I do not like the content to be changing when I am scrolling) or reset the listbox and scroll to the top (ugly in my opinion)

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