Windows Phone: ListPicker Problems and Solutions

In this post, I’m going to share my experience dealing with ListPicker which come from Silverlight for Windows Phone Toolkit (Sept 2010 edition). ListPicker is a very useful control to replace combo box type of control in Windows Phone, but currently version is too buggy and lot of work around needed. Here I’m share about the problem I face when using ListPicker and solution that I apply. Hope you can find it useful.

 

ListPicker Can’t Expend or Open Problem

This is a known bug in ListPicker. If you place the ListPicker in a ScrollViewer and the ListPicker can’t open in the full mode when user tap on it. The solution for this is manually open the ListPicker in FullMode when tap event is rise.

 

ListPicker Unable to Assign SelectedItem on Load / After User Select in Full Mode

Often we want to pre-select a SelectedItem in ListPicker which the application saved when the page load. The problem is if set  SelectedItem in page contractor like other controls, it still remain selecting the first item instead because it wasn’t loaded when you assigning  SelectedItem. If set on  PhoneApplicationPage_Loaded, it will work for the first time but when user tap on ListPicker and select a new value in full mode, the ListPicker will still remain the same SelectedItem. This is because  PhoneApplicationPage_Loaded will be call every time the page is load which mean when ListPicker full mode closed,  PhoneApplicationPage_Loaded will be call again and reset ListPicker SelectedItem again.

The solution for this is to put the SelectedItem in PhoneApplicationPage_Loaded event but make sure it is call one time only instead every time PhoneApplicationPage_Loaded is called. One way to do this use a class properties to keep track whatever ListPicker is initialized or not.

 

 

ListPicker Slow Performance Issue

If you have multiple ListPicker in the same page, you might notice the page will become unresponsiveness for the first one or two seconds when user navigate to the page. This is because multiple ListPicker take quite some time to load if you assign ItemSource in ListPicker during page constructor, on PhoneApplicationPage_Loaded event or on  OnNavigatedTo event. Setting  the CacheMode to BitmapCache won’t have solving the problem because it still need to load it for the first time.

I need the page to be responsiveness as soon as user navigate to the page. The only solution I can come out to solve this problem is to only load ItemSource to ListPicker when ListPicker is tap. Although this will cause ListPicker to open slower when user tap on it, but it is OK for me since I had more than 4 ListPicker and those ListPicker is just optional. Make sure you only assign ItemSource once instead of every time user tap on it.

 

That all for ListPicker currently. I hope all this information is useful for any one who face problem on ListPicker.

 

by Ooi Keng Siang via Ooiks’s Blog

5 thoughts on “Windows Phone: ListPicker Problems and Solutions

  1. I cannot thank you enough for this thoughtful analysis of why resetting ListPicker items is so tricky. I used your idea of the isInit class inside the page OnNavigatedTo event and it worked like a charm to stop the ListPicker wrongly resetting to the initial value after I’d changed the item.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s