在编辑模式下创建第一行 [英] Make the first row in edit mode
本文介绍了在编辑模式下创建第一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
WPf Datagrid。我在视图中有一个按钮;当我点击它。它在网格中插入新的空白行。
WPf Datagrid. I have a button in the view; when I click it. It insert the new blank row in the grid.
public ObservableCollection<MyModel> GridCollection { get; set; }
public void AddNewRow()
{
GridCollection.Insert(0, new MyaModel());
}
我的要求是我想要第一行中的所有单元格,无论是文本框还是组合框。网格中的其余行仍然只是只读。
My requirement is that I want all the cells in the first row, either a textbox or combobox. The rest rows in the grid are still readonly only.
<DataTemplate>
<TextBox Text="{Binding Name}">
<TextBox.Style>
<Style TargetType="TextBox">
<Style.Triggers>
<DataTrigger Binding="{Binding EditVisibility" Value="Visible">
<Setter Property="IsReadOnly" Value="True" />
</DataTrigger>
我的尝试:
我使用
What I have tried:
I use the
<DataGridTemplateColumn.CellTemplate>
来触发样式,但它适用于所有行。
也许我必须使用行为或CellEditingTemplate?
to trigger the style, but it applyed to all rows.
Maybe I have to use behavior or CellEditingTemplate?
推荐答案
我做了一个快速的谷歌搜索:如何禁用wpf datagrid行 - Google搜索 [ ^ ]
发现这个:无法使用样式触发器禁用WPF DataGrid中的行 - 堆栈溢出 [ ^ ]
I did a quick Google Search: how to disable wpf datagrid row - Google Search[^]
And found this: Unable to disable rows in WPF DataGrid using Style trigger - Stack Overflow[^]
这篇关于在编辑模式下创建第一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文