I think this has a trivial answer but I'm not getting it. Basically I have a Windows Phone 8 app that contains a Pivot, and application bar. I want to hide the application bar when a certain page in the Pivot is navigated to.
What I did was add the following code in the Pivot_SelectionChanged
event:
AppBar.IsVisible = !((((Pivot)sender).SelectedIndex) == 2);
So when the 3rd page is shown, the Application Bar is hidden, and should be shown when the 3rd page is navigated away from. However, when I run the app, I get a NullReference error for the AppBar.
I tried to put it inside Dispatcher.BeginInvoke
:
Dispatcher.BeginInvoke(() => {
AppBar.IsVisible = !((((Pivot)sender).SelectedIndex) == 2);
});
It works for the first few swipes, but on causes a NullReference exception on the third page.
Am I totally on the wrong track or is there an easier way to do this?
Don't use the name given by you to the ApplicationBar
, use ApplicationBar property of the page instead:
ApplicationBar.IsVisible = !((((Pivot)sender).SelectedIndex) == 2);
i.e. Replace AppBar with ApplicationBar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With