如何在数据杂志上的列中禁用编辑内容



我想禁用DataGrid内部的编辑内容,例如,如果用户单击双击,他现在可以编辑一列,我想避免使用它... p>我尝试通过编写以下内容在我的DataGrid上设置IsReadOnly属性:

<DataGrid Grid.Row="1"  VerticalContentAlignment="Center" IsReadOnly="True">

但这对我不好,因为我想通过单击"删除"按钮在我的 DataGrid中删除行,如果我将此状态设置为datagrid

IsReadOnly="True"

然后我正在失去该功能...

,但我想我可以以某种方式将代码应用于仅禁用单元。

<Style TargetType="{x:Type DataGridCell}">
    <Setter Property="IsReadOnly" Value="True" />
</Style>

但不幸的是它不起作用:(

您可以将每个列的IsReadOnly属性设置为true:

<DataGrid>
    <DataGrid.Columns>
        <DataGridTextColumn ... IsReadOnly="True" />
    </DataGrid.Columns>
</DataGrid>

这应该禁用单元格的编辑,但仍然让您删除行。

最新更新