Silverlight 프로젝트에 ListBox가 있습니다. ListBox에서 ListItem을 제거하고 추가 할 때 다음 오류가 발생합니다.Silverlight에서 ListItem 제거
Operation not supported on read-only collection.
코드 :
public void btnUp_Click(object sender, RoutedEventArgs e)
{
if (lbChoices.SelectedItem != null)
{
ListBoxItem selectedItem = new ListBoxItem();
selectedItem.Content = lbChoices.SelectedItem;
selectedItem.IsSelected = true;
int selectedIndex = lbChoices.SelectedIndex;
if (lbChoices.Items.Count > 1)
{
if (selectedIndex > 0)
{
lbChoices.Items.Remove(lbChoices.SelectedItem);
lbChoices.Items.Insert(selectedIndex - 1, selectedItem);
}
}
}
}
먼저 감사합니다. 흥미롭게도, 위쪽 및 아래쪽 버튼으로 항목의 위치를 변경하고 싶습니다. – Selo