I have a pivot control with non data bound pivot items which have different kind of structure. all of them have simple text headers. How can we change the visibility of the headers based on orientation changes? what I want to achieve is, when the phone is in landscape i want the headers to be invisible and all the space to be utilized by the the respective contents inside the pivot items. I tried a lot, and the biggest problem is the panel that carries the headers is always taking the original height.(I tried to change font size, visibility etc...) Please help. Here is my code sample
<controls:Pivot x:Name="pvtMain" >
<controls:PivotItem x:Name="pvtItemOne" Header="My Header one">
<MyUserControls:UserControlOne/>
</controls:PivotItem>
<controls:PivotItem x:Name="pvtItemTwo" Header="My Header Two">
<MyUserControls:UserControlTwo/>
</controls:PivotItem>
<controls:PivotItem x:Name="pvtItemThree" Header="My Header Three">
<MyUserControls:UserControlThree/>
</controls:PivotItem>
</controls:PivotItem>
I am using Windows phone SDK 7.0 (for backwards compatibility reason)
This may work. Give it a try!!
void MainPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
if (e.Orientation == PageOrientation.Landscape || e.Orientation == PageOrientation.LandscapeLeft || e.Orientation == PageOrientation.LandscapeRight)
{
pvtItemOne.Header = null;
pvtItemTwo.Header = null;
pvtItemThree.Header = null;
pvtMain.Margin = new Thickness(0, -150, 0, 0);
}
else
{
pvtItemOne.Header = "My Header One";
pvtItemTwo.Header = "My Header Two";
pvtItemThree.Header = "My Header Three";
pvtMain.Margin = new Thickness(0);
}
}
By the way, you don't need to maintain any backward compatibility for 7.0 devices. Microsoft stopped support for those devices long back and Marketplace is closed for those.