Home Forums WPF controls Xceed DataGrid for WPF Xceed WPF DataGrid and LLBLGen Pro

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25974 |

    EntityCollection<PersonEntity> people = new EntityCollection<PersonEntity>();
    this.PeopleGrid.ItemsSource = people;

    Anyone got Xceed DataGrid to work with LLBLGen Pro, no matter what I try (self-service or adapter), clean project, simple entity, etc.. I always get :

    “value isn’t of the correct type”

    at SD.LLBLGen.Pro.ORMSupportClasses.EntityViewBase`1.System.Collections.IList.Contains(Object value)\r\n at System.Windows.Data.BindingListCollectionView.Contains(Object item)\r\n at System.Windows.Controls.ItemCollection.Contains(Object containItem)\r\n at Xceed.Wpf.DataGrid.DataGridControl.OnItemsChanged(NotifyCollectionChangedEventArgs e)\r\n at System.Windows.Controls.ItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)\r\n at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)\r\n at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)\r\n at System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)\r\n at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)\r\n at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)\r\n at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)\r\n at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)\r\n at System.Windows.Data.BindingListCollectionView.RefreshOverride()\r\n at System.Windows.Data.CollectionView.Refresh()\r\n at System.Windows.Data.CollectionView.EndDefer()\r\n at System.Windows.Data.CollectionView.DeferHelper.Dispose()\r\n at System.Windows.Controls.ItemCollection.SetCollectionView(CollectionView view)\r\n at System.Windows.Controls.ItemCollection.SetItemsSource(IEnumerable value)\r\n at System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)\r\n at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)\r\n at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)\r\n at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)\r\n at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)\r\n at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal)\r\n at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)\r\n at System.Windows.Controls.ItemsControl.set_ItemsSource(IEnumerable value)\r\n at QuotationClient.Page1..ctor() in C:\\DevRoot\\Development\\VistaPlatform\\QuotationClient\\QuotationClient\\Page1.xaml.cs:line 39″e.”

    I have no problem binding this to other controls including XamDataGrid. grr..

    Imported from legacy forums. Posted by MattCheshire (had 1937 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Matt,

    Looking at the Stack Trace, I can see where the problem comes from.

    Before chaging the DataGridControl`s ItemsSource, make sure to clear the list of selected items as well as the current item, as the DataGridControl will try to remove selected items that are not present in the new items source from the list of selected items. It will also try to clear the CurrentItem property if the new item source does not contain the actual CurrentItem.

    this.PeopleGrid.SelectedItems.Clear();
    this.PeopleGrid.CurrentItem = null;

    If the exception is still thrown, that means that your data source throws an exception for being passed a “null” parameter to its IList.Contains() method.

    Also, It is my opinion that it is a little weird that the IList.Contains() implementation of the data source throws an exception while the “expected” behavior would be for it to simply return false in such cases.

    If you still encounter the issue after having done both steps above, you can try using the DataGridCollectionView to wrap your data source. Effectively, because the DataGridCollectionView adds grouping, sorting and filtering capabilities over any data sources, we coded our own implementation of Contains, which should not throw any exceptions.

    this.PeopleGrid.ItemsSource = new DataGridCollectionView(people);

    Either way, I opened a bug report for this, to see if we can find a way to address this shortcoming. A fix is mostly sure <b>not</b> to make it in time for 2.0 ( if we do decide to implement something to workaround this limitation ).

    Imported from legacy forums. Posted by Marcus [Xceed] (had 3242 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.