I am trying to refresh the sorting on a CollectionViewSource
using Silverlight 3:
var MyView = Resources["SortedCart"] as CollectionViewSource;
MyView.View.Refresh();
XAML CollectionViewSource config:
<CollectionViewSource x:Key="SortedCart"
Source="{Binding Path=Model.CurrentCart, Source={StaticResource ViewModel}}" >
<CollectionViewSource.SortDescriptions>
<scm:SortDescription PropertyName="LineNumber" />
</CollectionViewSource.SortDescriptions>
</CollectionViewSource>
results in
'MyView.Refresh()' threw an exception of type 'System.Exception'
Data: {System.Collections.ListDictionaryInternal}
InnerException: null
Message: "Error HRESULT E_FAIL has been returned from a call to a COM component."
StackTrace: " at MS.Internal.XcpImports.CheckHResult(UInt32 hr)\r\n at
MS.Internal.XcpImports.Collection_Clear[T](PresentationFrameworkCollection`1 collection)\r\n at
System.Windows.PresentationFrameworkCollection`1.ClearImpl()\r\n at
System.Windows.PresentationFrameworkCollection`1.Clear()\r\n at
Telerik.Windows.Controls.GridView.GridViewBaseVirtualizingPanel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args)\r\n at
Telerik.Windows.Controls.GridView.GridViewBaseVirtualizingPanel.OnItemsChangedHandler(Object sender, ItemsChangedEventArgs args)\r\n at
Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.OnRefresh()\r\n at
Telerik.Windows.Controls.GridView.GridViewItemContainerGenerator.Refresh()\r\n at
Telerik.Windows.Controls.GridView.GridViewDataControl.ItemsSourceChanged(Boolean sourceChanged)\r\n at
Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsChanged(NotifyCollectionChangedEventArgs e)\r\n at
Telerik.Windows.Controls.GridView.BaseItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)\r\n at
System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)\r\n at
Telerik.Windows.Data.DataItemCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)\r\n at
Telerik.Windows.Data.DataItemCollection.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs e)\r\n at
Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)\r\n at
System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)\r\n at
Telerik.Windows.Data.QueryableCollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)\r\n at
Telerik.Windows.Data.QueryableCollectionView.RefreshAndRaiseCollectionChanged(NotifyCollectionChangedEventArgs args)\r\n at
Telerik.Windows.Data.QueryableCollectionView.OnSourceCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)\r\n at
Telerik.Windows.Data.QueryableCollectionView.Telerik.Windows.Data.IWeakEventListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.ReceiveWeakEvent(Object sender, NotifyCollectionChangedEventArgs args)\r\n at
Telerik.Windows.Data.WeakEvent.WeakListener`1.Handler(Object sender, TArgs args)\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.Data.ListCollectionView.RefreshOverride()\r\n at
System.Windows.Data.CollectionView.Refresh()"