Search code examples
c#windows-phone-8application-bar

Accessing applicataion bar from non UI class windows phone 8


In my windows phone app I've a non-UI class which will show and hide a pop up screen when called from the UI page.

I want to hide the application bar when the pop up is shown and show the appbar again when the pop up is closed.

Now the challenge here is I've a timer in the non UI class which handles the closing of the pop up. So from the UI class I can only start the pop up. Closing is controlled by the non UI class. So now I need to access the appbar from the non UI class.

Can any one help me if I can do it or any work around if this cannot be done. ?

Thank you.


Solution

  • Maybe making use of Popup.Closed Event would help:

    private void myPopup_Close(object sender, System.EventArgs e)
    {
       // get current Page
       var currentPage = ((App.Current as App).RootVisual as PhoneApplicationFrame).Content as PhoneApplicationPage;
        // hide popup
        currentPage.ApplicationBar.IsVisible = true;
    }