wpf - 我可以只编辑一行 WPF DataGrid 吗?

标签 wpf datagrid wpfdatagrid editing

我有一个要显示给用户的数据集,但我只希望他们能够编辑最新的(第一行)数据。我需要向他们显示其他行数据以供引用。我不必将所有内容都保存在同一个 DataGrid 中,但如果可能的话,我希望这样做。

我是 WPF 的新手,因此非常感谢任何帮助/想法!

最佳答案

明白了,我只是取消对第一行以外的任何行的编辑。

private void dataGridStats_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
{
    if (e.Row.GetIndex() != 0)
    {
        e.Cancel = true;
    }
}

关于wpf - 我可以只编辑一行 WPF DataGrid 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1496274/

相关文章:

wpf - 保持椭圆的高度和宽度缩放

c# - 检测阈值区域

javascript - Material-UI DataGrid 组件使用新状态数据刷新

wpf - 如何根据一列中的值更改 DataGrid 行的背景

c# - 如何在 XAML 中绘制分割数据绑定(bind)矩形?

c# - 我可以在不签署完全信任的情况下部署 XBAP 吗?

c# - 如何覆盖 DataGridRow 模板中的 AlternatingRowBackground?

c# - WPF DataGrid - 基于行动态绑定(bind) DataGridComboBoxColumn

c# - 即使集合没有改变,MVVM 从 ViewModel 刷新 Datagrid

c# - 将 DataGrid 绑定(bind)到 XmlDataProvider 时出现问题