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
560
ActiveDataItem, RecordAdded and ValueChanged event
posted

In my grid, I have a XamComboEditor with a ValueChanged handler.  Whenever that combobox value is changed, I need to set some default values based on the new value selected.

Here is my handler:

    private void MyCombo_ValueChanged(object sender, RoutedPropertyChangedEventArgs<object> e)

    {

      ViewModel.LoadDefaultValues(newValue, myGrid.ActiveDataItem as MyEntity);    

    }

This is working fine when I edit the data.  When I add a record to the grid, the ValueChanged event is fired but the ActiveDataItem is null, resulting in the LoadDefaultValues not doing it's job.

How do I respond to the combobox value changed in this case?  Is there a way to access the record that the grid is currently adding?

 

Parents
No Data
Reply
  • 2677
    posted

    Sorry for the lengthy time in response.  I hope the following explanationcan help someone.

    If there is no activeDataItem at the time when you need it, you can access the activeRecord.  That should not be null.  You can access the ActiveRecord and make a check to see if it is an AddRecord.  Then you will know if you should pass the activeDataItem or not.  Here is some sample code to demonstrate this.

    if(Grid.ActiveRecord.IsAddRecord)
    {
     //make some call to the viewmodel but pass it in the active record instead of the active DataItem
    }
    else
    {
     //do your normal routine with the ActiveDataItem
    }

    Hope this helps.

Children
No Data