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
781
Exception on edit XamComboEditor with binded ObservableCollection<String>
posted

Hi,

 my xamcomboeditor is binded to an ObservableCollection<String> . The values are shown correctly, but on adding a value i always catch this exception:

Infragistics.RequireEmptyConstructorException: The DataManager attempted to create an instance of the type ‘System.String’ which does not have an empty parameter list.

I know new String() doesn't work, but isn't the xamcomboeditor able to add some strings to an normal colelction of strings?

 

 

<Editors:XamComboEditor IsEditable="True" ItemsSource="{Binding SuggestedValues, Mode=TwoWay}" CustomValueEnteredAction="Add" />

  • 6759
    Verified Answer
    Offline posted

    Hi UgaAga,

    sorry for the late response.

    There is no way for the XamComboEditor to create new object(by itself) if it does not have a default constructor.

    For cases like this XamComboEditor expose an event called DataObjectRequested which is fired when new item should be constructed.  In this event's handle you should create the new object and pass it by setting it to "e.NewObject". However this solution will not work in the case with "String" data type. It is not a good idea in general to use a Simple Types as a data source.

    The only workaround I only can thing of is in that event handler to get the text that is typed in the editor by walking down the visual tree. After you have the string you can use it to cretae the String object and finally pass it to e.NewObject.

    If you use a complex type and specify a DisplayMemberPath the XamComboEditor will set the DataObject's property after you have provided the newly created object from DataObjectRequested.

    About the resources you have asked about - here a link to the help for XamComboEditor. You could take a look at the samples browser.

     

    Regards

     

  • 781
    posted

    Is there a solution?

    Where can i find a good tutorial, blog on xamComboEditor?