简体   繁体   中英

Get the selected item of a ListView

如何从WinRT中的ListView获取选定的项(对象)?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM