Hello,
I will set the active cell with following program code:
private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) { dg.Rows[0].Cells[1].IsActive = true; }
And I become a NullReferenceException. With the debugger I can see this cell with data.
Following program code with another row works correct:
private void LayoutRoot_Loaded(object sender, RoutedEventArgs e) { dg.Rows[1].Cells[0].IsActive = true; }
Can you help me, please.
Sure.
Assuming you have at least one data row available at Load time, you can do the following.
void Page2_Loaded(object sender, RoutedEventArgs e)
{
((RowsManager)this.DataGrid1.Rows[0].Manager).AddNewRowTop.Cells[0].IsActive = true;
}
-SteveZ
is there a way to do this if you are using the Add New Row Feature? ie set the 'Add New Row' to active when page loaded?
Steve,
thanks for your workaround.
Thomas
Thomas,
Thanks for the sample.
Essentially, whats happening, is you have IsOnCellActiveEditingEnabled turned on. And when the control loads, you set the cell as active, which tells the grid to put it in edit mode, however, at that point, we haven't even fully loaded, so its not even possible to create controls for the Cells and Rows.
It is a bug, i wrote it up, and it'll be fixed in the next SR. However, you can easily get around this for now.
So, to get around it, you need to delay setting the IsOnCellActiveEditingEnabled, until after you set the ActiveCell.
So, remove it from the xaml, and use the following code:
private void LayoutRoot_Loaded(object sender, RoutedEventArgs e)
dg.Rows[0].Cells[1].IsActive = true;
dg.EditingSettings.IsOnCellActiveEditingEnabled = true;
Thanks for the report, and I hope this helps,
Hi Steve,
in the attachment you can see my sample.