Issue resetting GroupPickerItemsPanel template

5 posts, 0 answers
  1. Spencer
    Spencer avatar
    10 posts
    Member since:
    Feb 2011

    Posted 18 Mar 2012 Link to this post

    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"];
                    }
  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 19 Mar 2012 Link to this post

    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 >>
  3. DevCraft banner
  4. Spencer
    Spencer avatar
    10 posts
    Member since:
    Feb 2011

    Posted 19 Mar 2012 Link to this post

    Thanks for the reply.
  5. Derek
    Derek avatar
    39 posts
    Member since:
    Aug 2012

    Posted 21 Apr 2012 Link to this post

    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?
  6. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 24 Apr 2012 Link to this post

    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 >>

Back to Top
DevCraft banner