Ok, thanks that works.
On the topic of attempting to automate/test the grid, can you give any advice as to how to go about this?
We are finding complications with the STA/Dispatcher trying to get keystrokes sent to the cells.
We are currently calling out test code from within DataGrid.Loaded event which takes the InsertionRow and basically iterates through the cells and attempts to 'type' in the contents by doing something like:
cell.Focus()
cell.BeginEdit()
grid.Dispatcher.Invoke(DispatcherPriority.Input, (Callback)delegate
{
foreach (char c in characters)
{
TextComposition textComposition = new TextComposition(InputManager.Current, Keyboard.FocusedElement, "my text");
TextCompositionEventArgs textCompositionEventArgs = new TextCompositionEventArgs(Keyboard.PrimaryDevice, textComposition);
textCompositionEventArgs.RoutedEvent = UIElement.TextInputEvent;
Keyboard.FocusedElement.RaiseEvent(textCompositionEventArgs);
}
}
);
.. go to next cell... loop
But the cells do not get populated.
I suspect this is because the thread running through Loaded is the Dispatcher/UI thread, and there are problems with the keys being sent.
A bit lost on this one.