By default, DataGridControl won’t take keyboard focus (e.g. call Focus() on it and nothing happens). From an earlier post on this forum, I’m given to understand that to get this to work you have to set CurrentColumn and CurrentItem to the starting column and item first.
Given: var view = Data.Tables[table.DbName].DefaultView; Grid.DataContext = new DataGridCollectionView(view);
I then tried: Grid.CurrentColumn = Grid.Columns;
But that failed because Grid.Columns is an empty list, even though for display purposes it did in fact pick up the columns and is happily displaying them. What am I doing wrong?
The same thing applies to Grid.Items; there’s also apparently the problem that with virtualization, you can’t be sure any given item will actually exist at any given moment. How do you set CurrentItem? (That’s something that’ll be needed for other purposes such as implementing cursor keys, so the question will arise in general.)
Imported from legacy forums. Posted by Russell (had 2089 views)
I found the solution to the first problem: it turns out that when you set Grid.DataContext, Columns and Items aren’t updated immediately. What you need to do is hook the Loaded event, at which time these things will be set, then you can access Columns and Items, thus: