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???)