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
760
XamDataGrid - XamMultiComboEditor - SelectedItem
posted

Hi,

I am getting a error while trying to set the "ItemSource" for a XamMultiColumnComboEditor from a XamDataEditor. I have a seperate solution as suggested in the previous post of mine. i get the following error:

When i pass the ItemSource by a StaticResource defined in the Xaml in the following format,

<Setter Property="ItemSource" Value="{Binding Source={StaticResource ABC}, Path=OpRiskSeDropDown}"/>

, it works.

In my case, I have to set as follows,

<Setter Property="ItemSource" Value="{Binding Source={StaticResource OpRiskSeDropDown}, Path=Data}"/>

and this pukes the above exception. The exception is while trying to set the "SelectedItem" inside the OnCoerceValue(Object Value) method.

protected

override object OnCoerceValue(object val)

        {

if (string.IsNullOrEmpty(SelectedValuePath) || ItemSource == null)

                SelectedItem = val;

else

            {

var querySource = ItemSource.Cast<object>();

var item = querySource.Where(obj => obj.GetType().GetProperty(SelectedValuePath).GetValue(obj, null).Equals(val)).FirstOrDefault();

if (item != null)

                {

                    SelectedItem = item;

                }

            }

return base.OnCoerceValue(val);

}

In my project, i get the DataContext from a different file and need to use it.

P.S. : When i look at the value in the OnCoerceValue method inside the XamMultiComboEditor class file i have created, to set the ItemSource, the value is a garbage value. I am not sure, why this is not recognizing the correct path.

Any suggestions?

Parents
No Data
Reply
  • 30945
    Offline posted

    Hello Venkata,

     

    Thank you for your post. I have been looking into it and the code seems similar as one sample that I have cretaed previously (the attached sample). There there is a custom XamMultiComboEditor class that derives from the ValueEditor, so it can be used as a XamDataGrid’s editor. The OnCoerceValue override in the XamMultiComboEditor in the sample is the same as you code snippet. I have tested the sample and I am not able to reproduce the error that you have described.

     

    Would you please modify the attached sample to show issue that you are having, in order to be able to investigate what might be causing it?

     

    Looking forward to hearing from you.

     

    Sincerely,

    Krasimir, MCPD

    Developer Support Supervisor - XAML

    Infragistics

    www.infragistics.com/support

    MultiComboAsEditor_.zip
Children