Roberto Salemi

Roberto Salemi

  • NA
  • 146
  • 140.9k

[WPF] DataGrid Read Only but not for new row

Apr 17 2015 9:11 AM
Hi,
I have a DataGrid (called dgSample), where I set IsReadOnly="True".

User can add a new Row, this row must be editable.

So in my model I set a property:
[DefaultValue(false)]
public virtual bool IsNewItem { get; set; }

where user add new row I set this property to true

So in my DataGrid I have:
<DataGrid.RowStyle>
<Style TargetType="DataGridRow">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsNewItem}" Value="True">
<Setter Property="IsReadOnly" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>

but the last Row is not editable, why?

Thanks.

Answers (3)