0

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.

Presse
  • 418
  • 1
  • 4
  • 23
  • 1
    You shouldn't be accessing your UI at all from your non-UI class, because it's a non-UI class. It should just signaling to a UI class that *it* should update the UI, such as through an event, callback, etc. How, specifically, can vary depending on context. – Servy Jun 04 '14 at 14:34
  • Its quite complex in my case because the class is used by many of the UI pages. So signalling is difficult. Is there a possibility to make this possible ? – Presse Jun 04 '14 at 14:37
  • Yes, there is. As I said, it should fire an event, accept a callback, return a `Task`, or some other comparable asynchronous mechanism whereby the UI can update *itself* at the appropriate time. – Servy Jun 04 '14 at 14:39
  • Can you provide me some link or something to learn in detail about it ? – Presse Jun 04 '14 at 14:41
  • 1
    Take a look at [this blog post](http://www.visuallylocated.com/post/2013/11/25/Update-Creating-a-custom-MessageBox-for-your-Windows-Phone-apps.aspx), it does exactly what you are trying to do. Search for `ApplicationBar` – Shawn Kendrot Jun 04 '14 at 16:08

1 Answers1

1

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;
}
Romasz
  • 29,662
  • 13
  • 79
  • 154
  • @Presse You are welcome. Note only that it's the code above is very simple and it should be improved. [Shawn Kendrot added nice link](http://www.visuallylocated.com/post/2013/11/25/Update-Creating-a-custom-MessageBox-for-your-Windows-Phone-apps.aspx) where you can find much information. – Romasz Jun 04 '14 at 17:01
  • Thanks. I'll check for sure. – Presse Jun 05 '14 at 06:34