Я использую Visual Studio 2010, WPF с C # 4.0, и, щелкая ячейку в DataGrid, я получил следующее исключение:
An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll Additional information: A TwoWay or OneWayToSource binding cannot work on the read-only property 'Column2' of type 'VindecoderUI.AcesData'.
Вот код, который у меня есть:
<DataGrid AutoGenerateColumns="False" Height="190" Name="nadaDataGrid" Width="304" FrozenColumnCount="1000" ItemsSource="{Binding Source={StaticResource nadaDataCollection}}" CanUserReorderColumns="False" CanUserResizeColumns="True" CanUserSortColumns="False" AlternatingRowBackground="#3F000000" CanUserResizeRows="False" SelectionMode="Single" SelectionUnit="Cell"
SelectionChanged="dataGrid1_SelectionChanged" AreRowDetailsFrozen="True" >
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding Path=NadaSeries}" Header="Nada Series" />
<DataGridTextColumn Binding="{Binding Path=NadaBS}" Header="Nada BS" />
<DataGridTextColumn Binding="{Binding Path=MSRP}" Header="MSRP" />
<DataGridTextColumn Binding="{Binding Path=GVWR}" Header="GVWR" />
<DataGridTextColumn Binding="{Binding Path=GCWR}" Header="GCWR" />
</DataGrid.Columns>
</DataGrid>
<Window.Resources>
<CollectionViewSource x:Key="nadaDataCollection"></CollectionViewSource>
<CollectionViewSource x:Key="acesDataCollection"></CollectionViewSource>
</Window.Resources>