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
Testing using the header name is a bad idea, since your code will break if you rename your panorama item headers, or localize them.
You could work out the selected index, but that would break if you re-ordered your items:
PanoramaItem selectedItem = (PanoramaItem)e.AddedItems[0];
int selectedIndex = mainPanorama.Items.IndexOf(selectedItem);
The most robust way would be to set a Tag on your Panorama Items and test for that:
XAML:
Code behind:
private void Panorama_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count < 1) return;
if (!(e.AddedItems[0] is PanoramaItem)) return;
PanoramaItem selectedItem = (PanoramaItem)e.AddedItems[0];
string strTag = (string)selectedItem.Tag;
if (strTag.Equals("places"))
// Do places stuff
else if (strTag.Equals("routes"))
// Do routes stuff
}