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
3160
TemplateAddRecord.DataItem is null
posted

I have a xamcombobox with selected value bound to a property on my entity class. 

When the user adds a new row to the grid I need to set the value of the bound property to a default value.  I want the combox to reflect that value. 

However, the dataitem for TemplateAddRecord is null until the user makes some change.  Since my combobox is bound to the dataitem (which is null) it does not display any value at all.

What is the best way to accomplish this?

 

Thanks,

Sam

 

Example:

In XAML <XamComboEditor Value = "{Binding DataItem.StateCode}"/>

In Grid_InitialzeTemplateAddRecord:

e.TemplateAddRecord.Cells["StateCode"]  = "CA"; // Set default to California.  Combobox should update to reflect this but it does not (because dataitem is null???)

 

Parents
No Data
Reply
  • 3160
    posted

    I created a small project to illustrate the issue discussed in the first post, plus a related issue.


    Issue 1 (discussed in the first post in this thread):
    When starting the attached example note that the gender dropdown does not display a value even though the cell value is set.
    Put the cursor in the name column and type something.  The Gender_SelectedItemChanged fires even though the underlying value has not changed from the time the record was initialized.  I dont beleive the SelectedItemChanged event should fire because the combobox should be binding to the value AFTER it is set in the InitializeTemplateAddRecord method.

    Issue 2:
    Highlight any of the previously saved rows and press delete.  For some reason Gender_SelectedItemChanged fires again (and throws an error).

    InfragisticsDataEntryTest.zip
Children