无法在WPF UI中滚动ListView [英] Not able to scroll ListView in WPF UI

查看:77
本文介绍了无法在WPF UI中滚动ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我正在研究XML驱动的UI.我的应用程序解析XML并根据解析的信息创建UI.

现在,在该用户界面中,我们可以拥有各种控件,例如TextBlock,TextBox,ComboBox,DatePicker,DockPanel,TabControl, ListView 等,以及任意组合.请参见下面的XAML.无论我们要在UI中添加什么控件,都将添加到 ParentStackPanel 中(您可以说它是所有控件的父级).

Hi friends,

I am working on an XML driven UI. My application parses an XML and create UI as per the parsed information.

Now in that UI, we can have various controls like TextBlock, TextBox, ComboBox, DatePicker, DockPanel, TabControl, ListView etc and in any combination. Please see below XAML. Whatever control we want to add in the UI, is added into the ParentStackPanel (you can say that it''s parent of all the controls).

<UserControl>
    <StackPanel Name="ParentStackPanel">
    ...
    </StackPanel>
</UserControl>




ParentStackPanel 的大小将随着越来越多的控件而不断增加. UI带有滚动条,以便用户可以上下滚动UI.

问题:
在滚动时,如果鼠标光标位于某个ListView上,则滚动在此处停止.请参见下面的XAML.您可以看到用户界面中有一个ListView.滚动工作顺利,但是当鼠标指针移到该ListView上时,滚动突然停止.




The size of ParentStackPanel will keep on increasing with more and more controls in it. UI comes with a scrollbar so that user can scroll the UI to go up and down.

The Problem:
While scrolling if the mouse cursor comes at some ListView, scrolling stops here. Please see below XAML. You can see that the UI have one ListView inside it. Scrolling works smoothly but it suddenly stops when mouse cursor reaches over that ListView.

<UserControl>
    <StackPanel Name="ParentStackPanel">
    <TextBlock />
    <TextBox />
    <ComboBox />
    <TabControl />
    <ListView /> Scrolling stops here
    <DatePicker />
    <TextBlock />
    <TextBox />
    </StackPanel>
</UserControl>



请让我知道,为什么会发生以及如何解决此问题.

提前谢谢.
Aseem Sharma



Please let me know, why it happens and how can I resolve this problem.

Thanks in advance.
Aseem Sharma

推荐答案

ListView不会将鼠标事件传播到其父项.有几种不同的处理方式. 此处描述的一种方法 [
ListView does not propagate mouse events to its parent. There are several different ways how you could handle it. One method described here[^].


这篇关于无法在WPF UI中滚动ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆