繁体   English   中英

listview的WPF MouseMove事件

[英]WPF MouseMove event of listview

在我的wpf应用程序中,当鼠标移动到mousemove事件中的不同项目时,我面临着从listview获取项目的问题。 例如,如果listview包含列为的项目,

    "one"
    "two"
    "three"
    ----

Then in mousemove event if my mouse moved over the item two then i have to get "two" in my code.

Please help me as i am very new to this WPF.
Regards
Ravi

这可能是一个非常简单的解决方案,但它似乎做了你想要它做的事情。

    private void listView_MouseMove(object sender, MouseEventArgs e)
    {
        var item = Mouse.DirectlyOver;

        if (item != null && item is TextBlock)
            Debug.Print((item as TextBlock).Text);
    }

我希望这有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM