Click here to Skip to main content
15,867,750 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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?
Posted
Updated 12-Aug-18 18:35pm

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900