Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1935
"Update" ActiveDataItem with XamComboEditor
posted

 

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?

 

Parents
No Data
Reply
  • 17559
    Verified Answer
    posted

    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.

    ComboBoxInDataGrid.zip
Children