Reputation: 1527
I am having a weird issue with my app. Even if I create a panorama page using the template from Visual Studio 2012, when I load the app, item 2 appears first, for a very short time, and then the view switches to item 1. I'm pretty sure it should not be acting like this. Any ideas what's happening?
<Grid x:Name="LayoutRoot">
<controls:Panorama Title="my application">
<!--Panorama item one-->
<controls:PanoramaItem Header="item1">
<Grid/>
</controls:PanoramaItem>
<!--Panorama item two-->
<controls:PanoramaItem Header="item2">
<Grid/>
</controls:PanoramaItem>
</controls:Panorama>
</Grid>
Upvotes: 0
Views: 752
Reputation: 9230
This is a standard panorama behavior. But you can fix it in this way:
<phone:PhoneApplicationPage
... some lines missed ...
Loaded="MainPage_OnLoaded">
<Grid x:Name="LayoutRoot">
<controls:Panorama x:Name="MainPanorama" Title="my application">
<controls:PanoramaItem x:Name="DefaultItem" Header="item1">
<Grid/>
</controls:PanoramaItem>
<controls:PanoramaItem Header="item2">
<Grid/>
</controls:PanoramaItem>
</controls:Panorama>
</Grid>
</phone:PhoneApplicationPage>
Item1 has a name, and subscription to Loaded event added.
Then in code-behind:
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
}
private void MainPage_OnLoaded(object sender, RoutedEventArgs e)
{
MainPanorama.DefaultItem = DefaultItem;
}
}
Upvotes: 2