Hello,
Very simple question.
I use a XamComboEditor in my XamDataGrid. I have set an SelectedItemChanged-event on this ComboEditor to compare the selected index to my DataModel.
The problem is, that the ActiveDataItem-property on the xamDataGrid isn't set when comboeditor is expanded. It is only set if I select a text-field or a numeric-field.
How can I get the DataItem that the ComboEditor refers to?
Hello Christian,
I have been researching the scenario that you are describing, and I believe that this issue may be caused because by default XamDataGrid commits the changes when the user navigates out of the cell and it lost focus. This is why the new value is not committed yet, when you handle the SelectedItemChanged. In order to achieve your requirements you can manually force the XamDataGrid to commit the changes as follows:
void x_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
xdg.ExecuteCommand(DataPresenterCommands.EndEditModeAndAcceptChanges);
xdg.ExecuteCommand(DataPresenterCommands.StartEditMode);
}
For further reference, please have a look at the attached sample.
If you need any further assistance on this matter, do not hesitate to ask.
I'm not sure if my last post got added correctly.
I'll just post this to give it some attention.
Sorry for any inconvenience!
Hello Elena,
I was able to solve my problem by using Dispatcher to invoke an Action inside the SelectedItemChanged event.
Dispatcher.BeginInvoke(new System.Action(() => { /* My code */ }), DispatcherPriority.Background);