I have managed to get DataGrid
to show new row for adding new item.
Problem i face now is i want data in the rest of wpf DataGrid
to be read only and only new row should be editable.
Currently this is how my DataGrid
looks.
<DataGrid AutoGenerateColumns="False" Name="DataGridTest" CanUserAddRows="True" Grid.Row="2" ItemsSource="{Binding TestBinding}" >
<DataGrid.Columns>
<DataGridTextColumn Header="Line" IsReadOnly="True" Binding="{Binding Path=Test1}" Width="50"></DataGridTextColumn>
<DataGridTextColumn Header="Account" IsReadOnly="True" Binding="{Binding Path=Test2}" Width="130"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
But since I have kept the columns read only, a new row also adds as read only which is what I don't want.
Try this MSDN blog
Also, try the following example:
Xaml:
CS:
Just simply use this
Style
ofDataGridRow
: