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
220
XamDataGrid - Issue with DataItems.Add
posted

Hi,

DataItems.Add() Method throwing a IndexOutOfRange Exception.

Below are the series of calls that i made,

1. DataItems.Add() -- added 10 records, I could see 10 records.

2. Applied filter via UI -- now i could see 5 records, and rest 5 hidden. (Awesome filtering options -  Xaml code for enabling filter - AllowRecordFiltering="true"  FilterUIType="LabelIcons" )

3. DataItems.Clear() --

4. DataItems.Add() -- Trying to add another 10 records.

Throwing a IndexOutOfRange Exception, while adding 6th record.

Is this an issue with XamDataGrid or am i doing some thing wrong.

Regards.

  • 69686
    Suggested Answer
    posted

    Hello,

    Try wrapping the objects that you add in the XamDataGrid in a collection and set the DataSource property and not add them in the DataItems collection.

    For example, add items in a BindingList<T> collection and then set the XamDataGrid's DataSource property to this BindingList. This should be working as expected.

    When adding new items, add them directly in the collection.