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

How to bind JumpList to Windows Phone Contacts?

2 Answers 70 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.
Jairo
Top achievements
Rank 1
Jairo asked on 21 Jul 2012, 05:08 PM
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 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 23 Jul 2012, 08:40 AM
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.

0
Jairo
Top achievements
Rank 1
answered on 23 Jul 2012, 01:24 PM
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
Tags
JumpList
Asked by
Jairo
Top achievements
Rank 1
Answers by
Todor
Telerik team
Jairo
Top achievements
Rank 1
Share this question
or