0

I have one ListView and one observableCollection. I put observableCollection into the listView. I want to know how can i select multiple items in the listview with an other observable collection ?

I try to do : this.listView1.SelectedItems.Add(object);

But it didn't work.

Someone know how can I do it ?

I'm programming an application to windows 8.1 so i use winRT

2
  • I think you will find you answer in this post: stackoverflow.com/questions/83945/listview-multiple-selection Basically you need to either initialise your this.listView1.MultiSelect = true; and then create the onSelected function that keeps a count of the indexes that are selected. Jul 31, 2014 at 7:47
  • I don't know how can i do that.I just want selected multiple items into listview with programmation.
    – Moussawi
    Jul 31, 2014 at 8:01

2 Answers 2

2

Try as below

for (int i = 0; i < listObject.Length; i++)
   listView1.Items.FindByValue(listObject[i].id).Selected = true;
1
  • the method FindByValue() does not exist i'm programming to Windows 8.
    – Moussawi
    Jul 31, 2014 at 8:09
0

I've found the solution to my problem.

I think that it's not perfect but it's worked.

ObservableCollection<Object> obsObject = CR.GetListObject(Id);
LV_LIST_OBJECT.SelectAll();
foreach(var Item in LV_LIST_OBJECT.Items)
{
   bool bFound = false;
   if(Item.GetType() == typeof(Object))
   {
       foreach(Object obj in obsObject)
       {
           if (((Object)Item).ID_Object == obj.ID_Object)
           {
               bFound = true;
               break;
           }
   }
   if(!bFound)
   {
       LV_LIST_Object.SelectedItems.Remove(Item);
   }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.