我在编辑DataGrid
.
当我双击一个单元格时,会引发异常 -InvalidOperationException 'EditItem' is not allowed for this view
我正在寻找在数据网格中编辑单元格的最简单方法。
XAML------------------------------------------------- ------------------XAML
<DataGrid x:Name="ZdarzeniaDataGrid" AutoGenerateColumns="False" CanUserAddRows="True" HorizontalAlignment="Left" Margin="71,398,0,0" VerticalAlignment="Top" Height="279" Width="1119">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding IdZdarzenia}" Header="Id Zdarzenia" Width="100"/>
<DataGridTextColumn Binding="{Binding Gospodarze}" Header="Gospodarze" Width="100"/>
<DataGridTextColumn Binding="{Binding Goście}" Header="Goście" Width="100"/>
<DataGridTextColumn Binding="{Binding Kurs1}" Header="Kurs 1" Width="100"/>
<DataGridTextColumn Binding="{Binding Kurs0}" Header="Kurs 0" Width="100"/>
<DataGridTextColumn Binding="{Binding Kurs2}" Header="Kurs 2" Width="100"/>
<DataGridTextColumn Binding="{Binding Kurs10}" Header="Kurs 10" Width="100"/>
<DataGridTextColumn Binding="{Binding Kurs20}" Header="Kurs 20" Width="100"/>
<DataGridTextColumn Binding="{Binding Kurs12}" Header="Kurs 12" Width="100"/>
<DataGridTextColumn Binding="{Binding DataZdarzenia}" Header="Data Zdarzenia" Width="100"/>
</DataGrid.Columns>
</DataGrid>
C# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - C#
ZdarzeniaDataGrid.Items.Add(
new { IdZdarzenia = napis.ItemArray.GetValue(0).ToString(),
Gospodarze = napis2.ItemArray.GetValue(0).ToString(),
Goście = napis3.ItemArray.GetValue(0).ToString(),
Kurs1 = napis.ItemArray.GetValue(3).ToString(),
Kurs0 = napis.ItemArray.GetValue(4).ToString(),
Kurs2 = napis.ItemArray.GetValue(5).ToString(),
Kurs10 = napis.ItemArray.GetValue(6).ToString(),
Kurs20 = napis.ItemArray.GetValue(7).ToString(),
Kurs12 = napis.ItemArray.GetValue(8).ToString(),
DataZdarzenia = napis.ItemArray.GetValue(9).ToString()
});