This is a migrated thread and some comments may be shown as answers.

Changing ItemSource/GroupDesc/SortDesc/ItemTemplate causing Exceptions

4 Answers 98 Views
JumpList
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Warren
Top achievements
Rank 1
Warren asked on 12 May 2011, 09:29 PM
When I open a new page and initialize a RadJumpList everything works.
With the first list of content working and when changing a setting (through an applicationbar menu item) and then refresh the content It throws an application exception.

The idea is that the jumplist displays items using a particular ItemTemplate, GroupDescriptors, SortDescriptors and ItemSource based on a application setting.  The real difference is just the itemtemplate and itemsource data with one having more details then the other.

Everything works if I always change the setting at the main page before navigating to a new page.  Which a user should not have to do when changing the setting.

Private Sub GetServices(serviceList As Object)
    RadJumpList.IsAsyncBalanceEnabled = True
    radJumpList.GroupDescriptors.Clear()
    radJumpList.SortDescriptors.Clear()
    If appSettings.GetServicesSlimSetting Then
        radJumpList.ItemTemplate = ItemTemplateSlim
        serviceList = CType(serviceList, List(Of ServiceInfoSlim))
        Dim groupByServer As New GenericGroupDescriptor(Of ServiceInfoSlim, String)(Function(server) server.Server)
        radJumpList.GroupDescriptors.Add(groupByServer)
        Dim sortByService As New GenericSortDescriptor(Of ServiceInfoSlim, String)(Function(server) server.Caption)
        radJumpList.SortDescriptors.Add(sortByService)
    Else
        radJumpList.ItemTemplate = ItemTemplate
        serviceList = CType(serviceList, List(Of ServiceInfo))
        Dim groupByServer As New GenericGroupDescriptor(Of ServiceInfo, String)(Function(server) server.Server)
        radJumpList.GroupDescriptors.Add(groupByServer)
        Dim sortByService As New GenericSortDescriptor(Of ServiceInfo, String)(Function(server) server.Caption)
        radJumpList.SortDescriptors.Add(sortByService)
    End If
    radJumpList.ItemsSource = serviceList
End Sub

The exception is always thrown as the GroupDescriptors.Add

InvalidCastException
   at System.Linq.Enumerable.<CastIterator>d__b0`1.MoveNext()
   at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`4.GetEnumerator()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
   at Telerik.Windows.Data.DataGroup.InitItems(IEnumerable items)
   at Telerik.Windows.Data.DataGroup.set_Items(IEnumerable value)
   at Telerik.Windows.Data.GroupProcessor.ProcessDataGroups(IDescriptorProcessor descriptor, IEnumerable data)
   at Telerik.Windows.Data.GroupProcessor.ProcessDescriptor(IDescriptorProcessor descriptor, Int32 level, IEnumerable data)
   at Telerik.Windows.Data.GroupProcessor.ProcessCore(IEnumerable data)
   at Telerik.Windows.Data.DescriptorProcessor.Process(IEnumerable data)
   at Telerik.Windows.Data.RadCollectionView.CreateView()
   at Telerik.Windows.Data.RadCollectionView.RefreshOverride()
   at Telerik.Windows.Data.RadCollectionView.Refresh()
   at Telerik.Windows.Data.RadCollectionView.OnResumed(Boolean update)
   at Telerik.Windows.Controls.SuspendableObject.Resume(Boolean update)
   at Telerik.Windows.Data.RadCollectionViewSource.RefreshOverride()
   at Telerik.Windows.Data.RadListSource.Refresh()
   at Telerik.Windows.Data.RadCollectionViewSource.OnGroupDescriptorsChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, DataDescriptor item)
   at System.Collections.ObjectModel.Collection`1.Add(DataDescriptor item)
   at TSOL.WCF.Client.ServicesPage.GetServices(Object serviceList)
   at TSOL.WCF.Client.ServicesPage.GetServicesCompleted(Object sender, GetServicesCompletedEventArgs e)
   at TSOL.WCF.Client.ServiceReference.WMIServiceClient.OnGetServicesCompleted(Object state)
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
   at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at System.Delegate.DynamicInvokeOne(Object[] args)
   at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(Object[] args)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
   at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
   at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
   at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
   at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult)

4 Answers, 1 is accepted

Sort by
0
Victor
Telerik team
answered on 17 May 2011, 03:02 PM
Hello Warren,

 Thank you for writing.
You first have to assign the new ItemsSource and then add new group descriptors. What is happening is that you have a list of ServiceInfos but are giving the jump list a GroupDescriptor of ServiceInfoSlim. Since you can not cast from ServiceInfoSlim to ServiceInfo the binding logic fails. Just move the assignment of the ItemsSource property before your If statement.

Please write again if you have other questions.

Best wishes,
Victor
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Rajasekar
Top achievements
Rank 1
answered on 15 Jun 2012, 09:09 PM
Hi,

Is this issue resolved? When i try to assign a collection to ItemSource property of RadJumpList multiple times, it seems to be showing wrong results (or cached?). However setting the value to null and then assigning the new collection seems to work, but flickers a bit. Is this the only solution, please let know.
0
Deyan
Telerik team
answered on 20 Jun 2012, 08:06 AM
Hello Rajasekar,

The issue that you report does not seem to be related to the issue discussed in the previous posts on this thread and we are currently not aware of similar problems.

Since we are using similar scenarios in our Demos app and do not experience any issues I believe that you might have some specific code on your side that causes this. Can you please share with us some further details like code snippets or a functional demo app that we can use to reproduce the case here? Please note that you will have to open a new support ticket in order to be able to attach your project.

Thanks for your time.

Regards,
Deyan
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Rajasekar
Top achievements
Rank 1
answered on 21 Jun 2012, 02:16 PM
Hi Deyan,

Apologize that this is not the thread. I will post sample code as well as problem in another new thread. Thank you for the update.
Tags
JumpList
Asked by
Warren
Top achievements
Rank 1
Answers by
Victor
Telerik team
Rajasekar
Top achievements
Rank 1
Deyan
Telerik team
Share this question
or