ListView Windows 8 multiple indexes

会有一股神秘感。 提交于 2019-12-08 08:30:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!