Silverlight Block UI thread in OnNavigatingFrom
In my Silverlight application I want to show a child window wh开发者_StackOverflow社区ich prompts the user if he want to leave the page or stay.
The problem is that the UI thread continues to execute when showing the child window. Therefore I am not able to set NavigatingCancelEventArgs.Cancel
according to the Result of the child window.
How can I solve this problem?
Thanks
One way way to solve this problem is add an instance variable to your page. Let's call it allowNavigate and set it initially to false. Then when the navigation happens and allowNavigate != true, cancel the navigation and invoke your confirmation dialog. When that dialog completes with a result indicating that the user wants to navigate away from the page, set allowNavigate to true and repeat the navigation programatically.
精彩评论