Search code examples
xamlwin-universal-app

UWP ListView ItemClick


I have defined ItemClick event handler for a ListView. The event handler is called, but when I click the ListViewItem for the first time SelectedItem of the ListView is null and SelectedIndex is -1. But I want to retrieve SelectedItem also on the first click when nothing is selected in the ListView. Is there another solution? Thanks.


Solution

  • The answer is an easy one.

    `ItemClickEventArgs`
    

    contains attribute ClickedItem which is type of type DataContext of ListView.