I am attempting to detect the current panorama item that a user is currently on and then toggle an application bar icon button isenabled property accordingly. I have not had any luck on how to implement a feature like this, or properly detect the current panorama item. Specifically, I would like to use the selectedItem property and detect the name of the panorama items instead of the selectedIndex property because the panorama items may change their order. Is there any way to do this? So far what I have is the following:
MainPage.xaml
<controls:Panorama SelectionChanged="PanoramaItemSelectionChanged">
<!--Panorama item one-->
<controls:PanoramaItem Header="statuses" >
...
</controls:PanoramaItem>
<!--Panorama item two-->
<controls:PanoramaItem Header="mentions" >
...
</controls:PanoramaItem>
<!--Panorama item three-->
<controls:PanoramaItem Header="messages" >
...
</controls:PanoramaItem>
<!--Panorama item four-->
<controls:PanoramaItem Header="favorites" >
...
</controls:PanoramaItem>
</controls:Panorama>
MainPage.xaml.cs
private void PanoramaItemSelectionChanged(object sender, SelectionChangedEventArgs e)
{
string currentPanoramaItem = e.AddedItems[0] as string;
switch (currentPanoramaItem)
{
case "statuses":
//show application bar button?
break;
case "mentions":
//show application bar button?
break;
case "messages":
((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
break;
case "favorites":
//show application bar button?
break;
default:
return;
}
}
my SelectionChanged implementation does not work for some reason. Any ideas (with an example please)?