First of all i would like to say that im very glad to start my first blog. I’ll write here some ideas on WP7 and C# programming.

My first post will be rather short. It is dedicated to weird bug in Pivot control  that comes with Windows Phone 7 SDK.

Short description:

1. You create a markup with pivot control and some pivot items in it.  Important Note: At least 1 pivot item should have complex header. By complex i mean a non-string header but a header with some controls in it.
2. At some point in application flow you want to remove the PivotItem from Pivot.

Here you probably will get an ArgumentException like on the image below


It is hard to say what exactly causes this exception, but it seems that there is a but in logic that manages headers in Pivot control.

For the project i’m currently working on i created a workaround. It is a class derived from Pivot that has 3 methods that help with this task.

In current implementation when user tries to scroll to hidden pivot item it just skips it. To keep UI consistent we make pivotItem Header null and restore it to previous value when UnHidePivotItem is called.


Links to sources:

1. https://www.dropbox.com/s/uqb4p2rqczybbik/PivotWithHiding.cs – class only
2. https://www.dropbox.com/s/ls281kfsa3ibvgr/PivotRemoveBugWorkaround.zip – full project where you can remove and add pivot items by clicking appBarButtons


5 thoughts on “Windows Phone 7 : ArgumentException “The parameter is incorrect” bug in Pivot.Remove()

  1. Thanks for writing this up. I’ve been having a similar issue and have been thinking that I must have did something wrong with my binding, but it turns out to be a bug.

    Great job.

  2. Would it work if there are a couple of pivot items to hide and show again? I my project, there was a need to hide and show more than one pivot item at a time but I couldn’t do it as it gave an error message saying “Element is already the child of another element.” I would really appreciate it if you have any suggestion.

    Still a great work around for the bug.

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s