How to bind JumpList to Windows Phone Contacts?

3 posts, 0 answers
  1. Jairo
    Jairo avatar
    2 posts
    Member since:
    Jul 2012

    Posted 21 Jul 2012 Link to this post

    Hi,

    I'm trying to bind JumpList to Microsoft Windows Phone Contacts but I'm having a cast problem. 

    Anybody can help me with a sample?

    See my code below.

                Contacts contacts = new Contacts();
                //Identify the method that runs after the asynchronous search completes.
                contacts.SearchCompleted += new EventHandler<ContactsSearchEventArgs>(Contacts_SearchCompleted);
                //Start the asynchronous search.
                contacts SearchAsync(String.Empty, FilterKind.None, null);
    ...

            void Contacts_SearchCompleted(object sender, ContactsSearchEventArgs e)
            {
                try
                {
                    //Bind the results to the jump list that displays them in the UI
                    jumpList.DataContext = e.Results; //<==Exception here...
                }
                catch (System.Exception)
                {
                    //That's okay, no results
                }
            }  
  2. Todor
    Admin
    Todor avatar
    778 posts

    Posted 23 Jul 2012 Link to this post

    Hi Jairo,

    Thank you for your interest in RadJumpList.

    I tried to reproduce the exception that you described, but I couldn't. There was no exception, but there was no data in the JumpList, because simply setting the DataContext is not enough. You can see how to use the DataContext property here. To get the items, you need to set the ItemsSource property of the RadJumpList. Then the items should show, but still they won't be grouped until you add a group descriptor. We have examples in our online documentation. Here is how you can modify your code to display the contacts, grouped by the first letter of their name:
    void Contacts_SearchCompleted(object sender, Microsoft.Phone.UserData.ContactsSearchEventArgs e)
    {
        try
        {
            //Bind the results to the jump list that displays them in the UI
            radJumpList.ItemsSource = e.Results;
     
            GenericGroupDescriptor<Microsoft.Phone.UserData.Contact, string> groupByFirstName =
                new GenericGroupDescriptor<Microsoft.Phone.UserData.Contact, string>(contact => contact.DisplayName.Substring(0, 1).ToUpper());
     
            radJumpList.GroupDescriptors.Add(groupByFirstName);
        }
        catch (System.Exception)
        {
            //That's okay, no results
        }
    }

    I hope this information helps. Let me know if you still get an exception or if I can assist you further.

    Kind regards,
    Todor
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Jairo
    Jairo avatar
    2 posts
    Member since:
    Jul 2012

    Posted 23 Jul 2012 Link to this post

    Hi Todor,

    the exception occurred because I misunderstood the use of GenericGroupDescriptor .

    Your answer has helped me understand the proper use.

    Problem solved. Thanks a lot!

    Jairo Marques
    Direction Systems
Back to Top