WPF ListView的项目鼠标悬停 [英] WPF ListView MouseOver Item
本文介绍了WPF ListView的项目鼠标悬停的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有关WPF的列表视图,在鼠标悬停事件如何获得该项目的引用鼠标光标在?
For the wpf listview , in the Mouse Over event how do i get a reference to the item that the mouse cursor is on ?
问候,
MadSeb
Regards, MadSeb
推荐答案
您必须从ListViewItem的使用鼠标悬停事件鼠标已经结束,而不是从列表视图本身之一。
You have to use the MouseOver event from the listViewItem that the mouse is over, not the one from the listview itself.
public MainWindow() {
InitializeComponent();
ListView listView = new ListView();
ListViewItem listViewItem = new ListViewItem();
listViewItem.MouseMove += myMouseMoveEvent;
listView.Items.Add(listViewItem);
}
private void myMouseMoveEvent(object sender, MouseEventArgs e) {
ListViewItem item = (ListViewItem) sender;
// now you can handle the events with this item....
}
这篇关于WPF ListView的项目鼠标悬停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文