问题
When you have a ListView
in Windows 8 Metro Style Apps how can you get all the indexes selected supposing you have multiple selection enabled?
void itemsChanged (Platform::Object^ sender,
Windows::UI::Xaml::Controls::Controls::SelectionChangedEventArgs^ e
{
// get selected indexes
}
回答1:
You would have to compare the SelectedItems property of the sender (the ListView) with the Items property. It appears that SelectedItems add to the collection and remove from the collection in the order items were selected (although this is not documented anywhere I can find).
回答2:
You could add index properties to the type of item you bind to your ListView
. Other than that - perhaps you don't really need an index?
回答3:
I found a solution with the suggestions received
auto v = itemsListView->SelectedItems;
auto l = itemsListView->Items;
std::list <unsigned int> v1;
for (int i=0; i < v->Size; i++)
{
unsigned int k;
l->IndexOf(v->GetAt(i),&k);
v1.push_back(k);
}
来源:https://stackoverflow.com/questions/14861293/listview-windows-8-multiple-indexes