Rob Kraft's Software Development Blog

Software Development Insights

How to programmatically switch to a new pivot item in Windows Phone 7

Posted by robkraft on April 3, 2011

I hope the title of my article does not mislead you, but I just learned today that you cannot programmatically change which pivot item is displayed in the pivot control from your C# code. Apparently this is a known bug:
http://stackoverflow.com/questions/4541020/pivotcontrol-item-changing-behavior-in-silverlight-windows-phone-7.

Unfortunately for me this is a fairly devasting problem because my whole user interface (UI) is based on the Pivot Control and I needed my search function in the application to send me to a specific PivotItem. But code like this does not work:

PivotControl.SelectedIndex = 3;

I spent an hour or two before I started writing my application trying to decide if a Pivot Control or non Pivot based UI would work best. Had I known that the pivotcontrol was not working as expected, I certainly would have not used it. Fortunately I have also been writing unit tests and using MVVM on this project which is going to make putting an entirely different UI on the application relatively simple. I estimate 2 to 8 hours. Of course since I only work on this on the evenings and weekends the calendar time is going to cost me a week.

I am using the latest Microsoft Phone Developer SDK (release in February 2011). Hopefully the next SDK will fix this bug.

Advertisements

3 Responses to “How to programmatically switch to a new pivot item in Windows Phone 7”

  1. Andras Kindler said

    Hi,

    PivotControl.SelectedIndex = PivotControl.Items[3] works fine for me, try it this way.

    Btw I’m using the 7.1 beta SDK.

  2. Lyndon said

    The Kettic PivotGrid Control support of full OLAP, Pivoting, tabular and compact layouts, filtering and sorting, group, and more functionalities.

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

 
%d bloggers like this: