Silverlight ListBox:如何查明用户当前是否正在拖动滚动条滑块?
场景:我有一个 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 业务应用程序模板一部分的标准 BusyIndicator。
只要用户在计时器事件触发时不拖动列表框的滚动条滑块,就可以正常工作。
问题:如果用户在显示 BusyIndicator 时拖动滚动条滑块,则此后滚动条将不再工作。即使释放鼠标左键,鼠标指针仍然被捕获到滑块上。我认为发生这种情况是因为 BusyIndicator 在拖动滑块时暂时夺走了滑块的焦点。
问题:有没有办法知道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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,没有状态/属性可以确定滑块是否被推动。
也就是说,您可以尝试通过处理MouseLeftButtonDown 和 Up 事件,但您可能还需要根据您的场景考虑其他事件(鼠标滚轮?)
也可以通过使用 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?)
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)