开发者

Is there a way to prevent that a WPF page was navigated away?

I'm building a WPF navigation app, with pages. I want to ask the user if he want to save the changes when he leaves a page.

开发者_C百科

Is there a way to do it?


Register for the NavigationService.Navigating event. Don't forget to remove your registration when you are done, since NavigationService sticks around basically forever.

When you get the Navigating event and there are changes, show a MessageBox to confirm with the user or give them a chance to save their data. If they hit Cancel, set e.Cancel = true to cancel the navigation.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜