Reputation: 403
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
Upvotes: 0
Views: 1639
Reputation: 403
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);
}
}
Upvotes: 0
Reputation: 192
Try as below
for (int i = 0; i < listObject.Length; i++)
listView1.Items.FindByValue(listObject[i].id).Selected = true;
Upvotes: 2