I'm learning to develop applications in Windows Phone (for Mango). While using an appbar in a Panorama page, i wish to change the menu items and button text etc. according to the page selected (like the Music+Videos app).
For this, i created the application bar in xaml as:
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar x:Name="appbar" IsMenuEnabled="True" IsVisible="True">
<shell:ApplicationBarIconButton Text="Add" IconUri="/add.png" x:Name="btn" Click="Addbtn"/>
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="Exit" x:Name="menuitem" Click="menubtn"/>
</shell:ApplicationBar.MenuItems>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
Then, i tried manipulating the controls by trying to access the appbar by its x:name
property in the SelectionChanged
event of the panorama page as:
private void PanoControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (PanoControl.SelectedIndex == 0)
appbar.IsMenuEnabled = false;
else if(PanoControl.SelectedIndex == 1)
menuitem.IsEnabled = false;
else if (PanoControl.SelectedIndex == 2)
{
appbar.IsVisible = true;
menuitem.IsEnabled = true;
}
}
When moving from one panorama page to other, an exception is generated. Please help me out. Is this even possible?
Also, i'm asking a question here for the first time. Please let me know if i missed out on something.
Thanks, Siddhant