Click here to Skip to main content
13,733,172 members
Rate this:
 
Please Sign up or sign in to vote.
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 12-Aug-18 9:35am
Updated 12-Aug-18 18:35pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Cookies | Terms of Service
Web01-2016 | 2.8.180920.1 | Last Updated 13 Aug 2018
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100