gurehbgui
gurehbgui

Reputation: 14694

Get the selected item of a ListView

how can I get the selected item (the object) from a ListView in WinRT?

Upvotes: 1

Views: 4625

Answers (1)

Damir Arh
Damir Arh

Reputation: 17865

Use the SelectedItem property. You can use binding:

<ListView x:Name="myListView" ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}" />

Or you can access the property from code behind:

var item = myListView.SelectedItem;

If your SelectionMode isn't Single use SelectedItems instead.

Upvotes: 1

Related Questions