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>
to trigger the style, but it applyed to all rows.
Maybe I have to use behavior or CellEditingTemplate?