开发者

WPF ListView MouseOver Item

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜