I was migrating my app from WP7 to WP8, and a funny thing is happening. I've a databound pivot who works perfectly in WP7. But, in WP8, the exact same code, doesn't load the first PivotItem. I've tried all the solutions in the question for WP7, none works (I want a solution, not an ugly workaround). I'm setting the DataContext in the constructor, the collection is OK, and everything should work. It only loads pivots when I scroll in the app. Anyone has any solution?
Databound pivot is not loading the first PivotItem in Windows Phone 8
4.3k Views Asked by gjulianm At
3
There are 3 best solutions below
0
On
If it helps i had the same problem, did an ugly fix but it worked..
pivotTest.SelectedIndex = 1;
pivotTest.SelectedIndex = 0;
0
On
I created a repro of this bug here: https://github.com/michaellperry/PivotIsBroken
It appears that the bug occurs because the content animation is not triggered. The selected index is not actually changing.
The ugly workaround that I employed is similar to DavidN's recommendation, but I had to insert a dummy page. Setting SelectedIndex to 1 with only one page throws an exception.
I can't repro any databinding issues with Pivot on WP8. There is a known issue with Panorama Databinding on WP8, but not Pivot. What exactly doesn't work for you?
Here's a basic WP8 Pivot Databinding code that works just fine for me.
C# code setting a DataContext to an observable collection of cows:
XAML code using that DataContext as the ItemSource and Binding PivotItem.Header and PivotItem.Content to the cow name.
Works just fine...