locked
How to force redraw of MainPage from event handler of a popup control?

    Question

  • In my app, we offer a couple of dialogs (using popup controls) to let users customized the drawing behavior of MainPage. After users change a control property in a popup dialog, and thus the event handler of that control is called, the MainPage should be redrawn. How can I do this? For now, we pass the MainPage as a reference parameter to the constructor of the popup dialog class. Is there any other way to force the redraw?
    Monday, February 04, 2013 2:14 PM

Answers

  • This is a small example that might support your scenario:

    {
     auto rootFrame = dynamic_cast<Windows::UI::Xaml::Controls::Frame^>(Window::Current->Content);
     if (!rootFrame->Navigate(TypeName(MainPage::typeid)))
     {
      throw ref new FailureException("Failed to navigate");
     }
     if (rootFrame->CanGoBack)
     {
      rootFrame->GoBack();
     }
    }

    • Proposed as answer by Jesse Jiang Wednesday, February 06, 2013 2:28 AM
    • Marked as answer by Jesse Jiang Friday, February 08, 2013 2:42 AM
    Monday, February 04, 2013 3:48 PM

All replies

  • This is a small example that might support your scenario:

    {
     auto rootFrame = dynamic_cast<Windows::UI::Xaml::Controls::Frame^>(Window::Current->Content);
     if (!rootFrame->Navigate(TypeName(MainPage::typeid)))
     {
      throw ref new FailureException("Failed to navigate");
     }
     if (rootFrame->CanGoBack)
     {
      rootFrame->GoBack();
     }
    }

    • Proposed as answer by Jesse Jiang Wednesday, February 06, 2013 2:28 AM
    • Marked as answer by Jesse Jiang Friday, February 08, 2013 2:42 AM
    Monday, February 04, 2013 3:48 PM
  • Thank you for your quick response, but where is the reference to MainPage in your code?
    Tuesday, February 05, 2013 12:48 AM
  • Hi Leonard,

    This is just sample code with the intention to navigate away then navigate back using the Navigation Stack. The idea is that by performing such manipulation, you force the page - you navigate away from then back to, from within the Popup [*] -, to refresh its contents. Feel free to use a similar approach given the state of your Navigation Stack in your specific scenario.

    ---
    [*] [I used in fact the SettingsPane which is UX conformant to adapt user parameters]

    Tuesday, February 05, 2013 7:07 AM