0
刪除custome項目我綁定一個可觀察cllection在silverlight.when一個列表框我在列表框中單擊一個項目,然後單擊刪除按鈕,如何刪除特定項目從列表框中使用MVVM刪除不LINQ。我通過按鈕的命令參數是listbox itemid。如何從的ObservableCollection在Silverlight
<ListBox ItemsSource="{Binding School1,Mode=TwoWay}" DisplayMemberPath="SchoolName" Name="listBox1" >
<Button Content="Delete" Command="{Binding deletecommand}" CommandParameter="{Binding Path=SelectedItem.ID,ElementName=listBox1}" Name="button2" />
究竟什麼是從觀察到的集合
public void delete(object parameter)
{
School1.Remove(...)
}
喜@slugs之三我爲selectedschool一個字符串屬性和binded.when我寫school1.remove(selectedschool)它使錯誤.. – nichu09
@ nixen09,什麼是錯誤?你是否在delete()函數的代碼中放置了一個斷點,以便你可以使用調試器來檢查那裏的值? – slugster
我清理那一個。我使用的selectedIndex和使用,我刪除observablecollection.when我使用所選項目的值,我得到了特別的classname.error是,它有一些無效argument.i寫這樣school1.remove(將selectedItem)的代碼。我試圖找到錯誤,當我使用selecteditem但我不能解決這個問題.. – nichu09