Skip to content

Listvew mouse event doesn't cause a selecteditemchange event to fire #3317

@dasien

Description

@dasien

Discussed in #3316

Originally posted by dasien March 13, 2024
Kind of a beginner here, so this could very likely be something i am doing wrong. I have a listview on which i am tracking the MouseClick, KeyUp, and SelectedItemChanged events. When the listview is first loaded, i set the selected item to the first item in the list. Also, the listview has AllowsMarking and MultiSelect set to true.

The first mouse click in the listview fires the MouseClick event 3 times and it fires the SelectedItemChanged event. Subsequent mouse clicks still fire the MouseClick event (3 times), but do not fire the SelectedItemChanged event. Inside the MouseClick, i am checking the listview.SelectedItem, and i do see that number changing from click to click, to the last row on which i clicked, but the SelectedItemChanged event isn't firing.

The issue for me is that i am using that Change event to track the current row in the listview, so that future operations can act on one, or a collection, of items associated with the selected rows.

Similar actions using the keyboard (moving between rows for example) seem to fire both the KeyUp event and SelectedItemChanged events every time.

Is there something i am doing incorrectly or out of order to not get that SelectedItemChanged event to fire? Alternatively, is there some way to compute the row which was clicked in the listview? I could then capture the item associated with the row which was clicked and store it in my list of selected items. Somehow the underlying system knows which row has been clicked, because it is tracking the change to the SelectedItem and marking the correct row with a check mark and highlighting that as the selected row.

Any ideas would be appreciated, and happy to share some code if needed. It is pretty straightforward for this part, just registering events and putting a breakpoint to check what is firing and when.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions