Hi,
i have a radgridview on my wpf app. This grids itemssouce is bound to a List of objects in my ViewModel (MVVM).
When i click on a Button a new element is added to the bound list. This creates a new Row in my DataGrid like expected.
Question:
i want to focus the last cell in the new row after the new row was added.
I already have the correct way of doing this (see snippet below) but i dont know WHEN i should execute this code. When the bound items are changed its too early to do this and i cant use events like "LayoutUpdated" because it triggers too often.
Is there any possibility to launch this code AFTER the GridViewRow was Added?
private void OnInitializedGridViewCommand(RadGridView obj)
{
obj.Items.CollectionChanged += (sender, e) =>
{
var grid = obj as RadGridView;
var rows = obj.ChildrenOfType<
GridViewRow
>().ToList();
if (rows.Count <
1
) return;
var
cells
=
rows
[rows.Count - 1].ChildrenOfType<GridViewCell>().ToList();
var box = cells[cells.Count - 1].ChildrenOfType<
RadComboBox
>();
box.First().Focus();
};
}