I have a datagrid which gets data like this:
public struct MyData
{
public string name { set; get; }
public string artist { set; get; }
public string location { set; get; }
}
DataGridTextColumn col1 = new DataGridTextColumn();
col4.Binding = new Binding("name");
dataGrid1.Columns.Add(col1);
dataGrid1.Items.Add((new MyData() { name = "Song1", artist = "MyName", location = "loc"}));
dataGrid1.Items.Add((new MyData() { name = "Song2", artist = "MyName", location = "loc2"}));
问题是,每当用户尝试编辑单元格或拖动多个单元格时,应用程序会抛出异常:
System.InvalidOperationException未处理
消息:此视图不允许“EditItem”。
为什么会这样?是因为数据输入的方式吗?
有什么想法吗?
谢谢!
List<T>
支持Add()
和Remove()
。 - Angshuman Agarwal