2011-11-01 87 views
0

我使用Silverlight Toolkit中的MultiselectList。當我檢查MultiselectList中的項目時,如何刪除這些項目?如何從MultiselectList中刪除項目?

這是C#示例:

for (int i = checkedListBox1.Items.Count - 1; i >= 0; i--) 
{ 
    if (checkedListBox1.GetItemChecked(i)) 
    { 
     checkedListBox1.Items.RemoveAt(i); 
    } 
} 

我需要爲Windows Phone的代碼示例7

回答

-1

使用下面的代碼

foreach(ListBoxItem item in listBox.SelectedItems) 
    { 
     listBox.Items.RemoveAt(listBox.SelectedIndex); 
    } 
+0

-1 Multiselect中沒有'SelectedIndex'名單。 –

+0

如果是給我的答案鏈接在wp7中是否有MultiselectList?根據這個鏈接http://stackoverflow.com/questions/3811343/silverlight-listbox-with-multiple-selection-mode我的回答是正確的。 – PCS

+1

Silverlight工具包中有一個MultiselectList:https://silverlight.codeplex.com/releases/view/71550 –

1

我會去與

while (multiselectList1.SelectedItems.Count > 0) 
    { 
     multiselectList1.Items.Remove(multiselectList1.SelectedItems[0]); 
    }