2012-05-15 62 views
1

我開發的Windows 8的應用程序,我想選擇一個GridView多個項目(由C#代碼),我嘗試這樣做:Windows 8中的GridView多選擇的項目

for (int i = 0; i <= 2; i++) 
{ 
    this.ItemGridView.SelectedIndex = i; 
} 

//in this way is only selects the third element 

第二

this.ItemGridView.SelectedItem = listPeople; 

//in this way does not select anything 
foreach (Persona persona in listaPersone) 
{ 
    this.ItemGridView.SelectedItem = person; 
} 

//in this way is selected only the last 

回答

2

你可以試試這個

假設「listPeople」是集要選擇什麼。

foreach(var p in listPeople) 
{ 
    this.ItemGridView.SelectedItem.Add(p); 
} 
0

我沒有嘗試對Win8的,但這樣的事情應該工作:

this.ItemGridView.MultiSelect = true; 

foreach (GridViewRow row in this.ItemGridView.Rows) 
{ 
    row.Selected = selection.Contains(row.Cells[0].Value); 
} 
相關問題