Reputation: 5474
I'm using a ReadOnly DataGrid to display some data in my WPF-application.
My question then is.
How can I make the last row editable ?
Upvotes: 1
Views: 2403
Reputation: 240
I have been working in windows forms not wpf and am fairly new to C# so there may be a better way to do this.
I encountered a similar problem and to get around it I made the table not read only, and then looped through all of the rows and set them individually to ReadOnly except for the last one. Not the prettiest but it worked.
foreach (DataRow dataRow in dataGridView.Rows)
{
dataRow.ReadOnly = true;
}
dataGridView.Rows[dataGridView.Rows.Count - 1].ReadOnly = false;
Upvotes: 0
Reputation: 12315
<DataGrid x:Name="dataGrid" AutoGenerateColumns="False" ItemsSource="{Binding Students}" LoadingRow="dataGrid_LoadingRow_1">
private void dataGrid_LoadingRow_1(object sender, DataGridRowEventArgs e)
{
if (e.Row.IsNewItem)
e.Row.IsEnabled = true;
else
e.Row.IsEnabled =false;
}
Upvotes: 3