Friday, March 23, 2012

ListPicker

One of the finest controls in the Silverlight toolkit for Windows Phone 7, is the ListPicker control. But I had to struggle with it for a while. It was mainly because I didn't understand it quite well. Below you would find the 2 scenarios where I had to stumble:

1. SelectedItem should be set to a valid item.
That was the error I was getting no matter what I did to pacify the control. I googled (with Bing of course), and I found lot of ramblings on how buggy the control was and how this error never vanishes. This annoyed me. I gave up and wrote a query on Stackoverflow. The answers quite did not point the exact cause, but it gave me a direction to hunt. And there I was.... I had a property (which was of a reference type - in my case, instance of a Category class) in my ViewModel which bound to the SelectedItem of the ListPicker. But on that page, when I was loading the elements, I was trying to bind a "string" (CategoryName, in my case).


2. The selected item from the ListPicker does not get set when using FullMode. 
The difference between ExpansionAllowed and using a FullMode for displaying the ListPicker, is that after picking the item in FullMode, the page loads again. That is, any initializing that you might have executes. You need to preserve the selected item of ListPicker before you call the initializing and then reset the selected item once initializing is over.



No comments:

Post a Comment

Cookies, anyone?

  Our application started having integration issues early March this year. Did I say that was intermittent? To add to our confusion, we coul...