开发者

WPF ListView MouseOver Item

开发者 https://www.devze.com 2023-01-27 01:22 出处:网络
For the wpf listview , in the Mouse Over event how do i get a reference to the item that the mouse cursor is on开发者_如何学Go ?

For the wpf listview , in the Mouse Over event how do i get a reference to the item that the mouse cursor is on开发者_如何学Go ?

Regards, MadSeb


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....
}
0

精彩评论

暂无评论...
验证码 换一张
取 消