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

Issue resetting GroupPickerItemsPanel template

4 Answers 63 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.
Spencer
Top achievements
Rank 1
Spencer asked on 18 Mar 2012, 09:35 PM
I'm building functionality that allows changing the filter and group picker.  Basically i have a phonebook style and normal default style.  What i'm seeing is once i display the group picker i can no longer change the template used.   Is there a special way you have to reset that?  Here's a sniplet of the code.

                RadJumpList list = null;

                // determine which list to manipulate
                if (args.ViewType == MainViewType.Favorites)
                {
                    list = this.favoriteJumpList;
                }
                else if (args.ViewType == MainViewType.Scenes)
                {
                    list = this.sceneJumpList;
                }
                else if (args.ViewType == MainViewType.Devices)
                {
                    list = this.deviceJumpList;
                }

                // reset the template info
                if (args.ViewType == MainViewType.Favorites)
                    list.GroupPickerItemTap -= FavoriteJumpListGroupPickerItemTap;
                else if (args.ViewType == MainViewType.Scenes)
                    list.GroupPickerItemTap -= SceneJumpListGroupPickerItemTap;
                else if (args.ViewType == MainViewType.Devices)
                    list.GroupPickerItemTap -= DeviceJumpListGroupPickerItemTap;
    
                list.GroupHeaderTemplate = null;
                list.GroupPickerItemsSource = null;
                list.GroupPickerItemTemplate = null;
                list.GroupPickerItemStyle = null;
                list.GroupPickerItemTemplateSelector = null;
                list.GroupPickerItemsPanel = null;
                list.StickyHeaderTemplate = null;
                list.GroupDescriptors.Clear();
                list.SortDescriptors.Clear();

                if (args.GroupByType == MainViewGroupByType.Alphabetical)
                {
                    GenericGroupDescriptor<VeraItem, string> groupBy = new GenericGroupDescriptor<VeraItem, string>(item => Regex.IsMatch(item.Name.Substring(0, 1).ToLower(), "^[a-z]{1}$") ? item.Name.Substring(0, 1).ToLower() : "#");
                    GenericSortDescriptor<VeraItem, string> sortBy = new GenericSortDescriptor<VeraItem, string>(item => item.Name);

                    list.IsStickyHeaderEnabled = true;

                    string alphabet = "#abcdefghijklmnopqrstuvwxyz";
                    List<string> groupPickerItems = new List<string>(32);
                    foreach (char c in alphabet)
                    {
                        groupPickerItems.Add(new string(c, 1));
                    }
                    list.GroupPickerItemsSource = groupPickerItems;
                    list.GroupDescriptors.Add(groupBy);
                    list.SortDescriptors.Add(sortBy);

                    if (args.ViewType == MainViewType.Favorites)
                        list.GroupPickerItemTap += FavoriteJumpListGroupPickerItemTap;
                    else if (args.ViewType == MainViewType.Scenes)
                        list.GroupPickerItemTap += SceneJumpListGroupPickerItemTap;
                    else if (args.ViewType == MainViewType.Devices)
                        list.GroupPickerItemTap += DeviceJumpListGroupPickerItemTap;

                    list.GroupHeaderTemplate = (DataTemplate)this.Resources["AlphabeticGroupHeaderTemplate"];
                    list.GroupPickerItemTemplateSelector = (DataTemplateSelector)this.Resources["PhoneBookStyleGroupPickerItemTemplateSelector"];
                    list.GroupPickerItemsPanel = (ItemsPanelTemplate)this.Resources["PhoneBookStyleGroupPickerItemsPanel"];
                    list.StickyHeaderTemplate = (DataTemplate)this.Resources["AlphabeticStickyHeaderTemplate"];
                }
                else if (args.GroupByType == MainViewGroupByType.Category || args.GroupByType == MainViewGroupByType.Room)
                {
                    if (args.GroupByType == MainViewGroupByType.Category)
                        list.GroupDescriptors.Add(new GenericGroupDescriptor<VeraItem, string>(item => item.Category));
                    else
                        list.GroupDescriptors.Add(new GenericGroupDescriptor<VeraItem, string>(item => item.Room));

                    list.IsStickyHeaderEnabled = true;

                    list.GroupHeaderTemplate = (DataTemplate)this.Resources["GroupTemplate"];
                    list.GroupPickerItemTemplate = (DataTemplate)this.Resources["GroupPickerItemTemplate"];
                    list.GroupPickerItemStyle = (Style)this.Resources["GroupPickerItemStyle"];
                    list.GroupPickerItemsPanel = (ItemsPanelTemplate)this.Resources["NormalGroupPickerItemsPanel"];
                    list.StickyHeaderTemplate = (DataTemplate)this.Resources["GroupTemplate"];
                }

4 Answers, 1 is accepted

Sort by
0
Kiril Stanoev
Telerik team
answered on 19 Mar 2012, 03:20 PM
Hi Spencer,

Thank you for contacting us. Unfortunately this scenario is currently not supported and we are not aware of an existing workaround.

The GroupPickerItemTemplate property is set to the ItemsTemplate property of a control named JumpListGroupPicker. JumpListGroupPicker is basically a System.Windows.Controls.ItemsControl. As far as I know, changing the ItemsPanel of a System.Windows.Controls.ItemsControl is not yet available in Windows Phone 7. The same scenario has been working properly in WPF. Some time ago the issue was present in Silverlight as well but Microsoft managed to fix it. The problem is that the fix has not been included in the last Windows Phone release. 

We will be able to achieve this scenario as soon as we manage to integrate our ListBox into the JumpList. Until then, there is not much we can do. Sorry for the inconvenience caused.

Greetings,
Kiril Stanoev
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Spencer
Top achievements
Rank 1
answered on 20 Mar 2012, 12:10 AM
Thanks for the reply.
0
Derek
Top achievements
Rank 1
answered on 21 Apr 2012, 05:51 PM
edit: I figured this out.

To make sure I understand:

If I have a jump list of customers, like the phone book example.  It's ItemsSource is bound to a collection of Customers.  On the initial load of Customers I have customer names that start with 'A' and 'B' so the template selector enables 'A' and 'B'.

If I refresh Customers and now have customer names that start with 'A', 'B', and 'C' the template won't update and 'C' will remain disabled?
0
Kiril Stanoev
Telerik team
answered on 24 Apr 2012, 02:05 PM
Hi Derek,

 The scenario you described is supported. What I meant in my previous post was that the ItemsPanel cannot be changed runtime:

The ItemsPanel property gets or sets the template that defines the panel that controls the layout of items. 

As for the DataTemplate of each item, it can be changed runtime using a template selector. Let me know if this answers your question.

Regards,
Kiril Stanoev
the Telerik team

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

Tags
JumpList
Asked by
Spencer
Top achievements
Rank 1
Answers by
Kiril Stanoev
Telerik team
Spencer
Top achievements
Rank 1
Derek
Top achievements
Rank 1
Share this question
or