开发者

Silverlight Block UI thread in OnNavigatingFrom

开发者 https://www.devze.com 2023-03-19 09:30 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消