WPF DataGrid:使单元格只读
我使用下面的DataGrid
<DataGrid Grid.Row="1" Grid.Column="1" Name="Grid" ItemsSource="{Binding}" AutoGenerateColumns="False" > <DataGrid.Columns> <DataGridTextColumn Header="Name" Width="100" Binding="{Binding Path=Name}"></DataGridTextColumn> <DataGridTextColumn Header="OldValue" Width="100" Binding="{Binding Path=OldValue}"></DataGridTextColumn> <DataGridTextColumn Header="NewValue" Width="100*" Binding="{Binding Path=NewValue}"></DataGridTextColumn> </DataGrid.Columns> </DataGrid>
我怎样才能使细胞只读?
将DataGrid的IsReadOnly属性设置为true。
<DataGrid Grid.Row="1" Grid.Column="1" Name="Grid" ItemsSource="{Binding}" IsReadOnly="True" AutoGenerateColumns="False" >