locked
Escaping the context of a Flyout or Popup?

    Question

  • In Win32 programming, if I was in the context of a call chain that I didn't want to be in, I could just PostMessage() my way out of it and have code on the Windows message loop pick up the message and execute a desired task outside of that context.

    I need something similar in WinRT.  I have found myself on more than one occasion with a flyout open and then a Popup on top of the Flyout triggered by an interaction with an element on the Flyout.  From that context I have found that various operations don't work well or frequently cause hard to diagnose Exceptions.

    For example, I have a Flyout that has thumbnails on it.  If you click on a thumbnail it opens a popup menu with menu choices on it.  Clicking on one of the menu choices allows you to edit the text associated with the thumbnail.  However, when the edit dialog, a popup itself, is activated in this context I get Exceptions.  The very same edit dialog when activated from outside this Flyout -> Popup context from the main grid works perfectly without error.

    What is the simplest way to delay a Task, like activating the edit popup, so that it occurs after the Flyout and child Popup have completely exited/closed down and whatever associated UI events have cleaned themselves up and out of the way?

     

    -- roschler

    Wednesday, February 19, 2014 7:33 AM

All replies

  • It's difficult to answer this question without specifics, but we usually use a dispatcher to invoke script on the UI thread or other thread wherever an object exists.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, February 20, 2014 1:23 PM
    Moderator