是否有关于如何在wpf数据网格上使用编辑模式的教程?下面这个简单的网格似乎无法编辑评论栏。
<DataGrid x:Name="_myDataGrid" AutoGenerateColumns="False" IsReadOnly="True" ItemsSource="{Binding}" SelectionMode="Single" CanUserResizeColumns="False" CanUserResizeRows="False">
<DataGrid.RowHeaderStyle>
<Style TargetType="DataGridRowHeader">
<Setter Property="Content" Value="{Binding doorNumber}" />
<Setter Property="MinWidth" Value="40" />
<Setter Property="Width" Value="Auto" />
</Style>
</DataGrid.RowHeaderStyle>
<DataGrid.Columns>
<DataGridTemplateColumn Header="Comment" MinWidth="100" Width="*" IsReadOnly="False">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding doorComment}" ToolTip="{Binding doorComment}" TextTrimming="CharacterEllipsis" IsHitTestVisible="False" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text="{Binding doorComment}" TextWrapping="Wrap" />
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
答案 0 :(得分:0)
更改IsReadOnly =&#34; True&#34;至 IsReadOnly =&#34; False&#34;