自定义异常处理(Custom exception handling)

编程入门 行业动态 更新时间:2024-10-15 04:20:40
自定义异常处理(Custom exception handling)

我在wp8.1中制作应用程序我想确保在某些过程中用户不允许按下Windows Phone的硬件后门按钮。 如果他这样做,那么我的自定义catch块异常应该运行。

我不知道如何处理我的应用程序的后退异常。 请提供您在制作自定义例外时提供的任何代码段或帮助。

谢谢

public class InvalidDataException : ApplicationException { public InvalidDataException() { } public InvalidDataException(string msg) : base(msg) { } }

I am making an app in wp8.1 I want to make sure that during certain process user is not allowed to press the hardware backbutton of windows phone. IF he does then my custom catch block exception should run.

I don't know how to handle the backbutton exception for my app. Please provide any snippet or help you can in making custom exception.

Thanks

public class InvalidDataException : ApplicationException { public InvalidDataException() { } public InvalidDataException(string msg) : base(msg) { } }

最满意答案

如果将BackPressedEventArgs(e)参数的Handled属性设置为True,则将阻止此事件的操作系统操作,您可以触发自定义异常。

当您将此属性设置为true时,操作系统将停止导航回来。但是,您不应该阻止用户终止您的应用程序。否则您的应用程序会更改为不进入商店。

If you set BackPressedEventArgs (e) parameter's Handled property to True , you will block the OS action on this event you can trigger your custom exception.

When you set this property to true OS will stop to navigate back.However , you shouldn't prevent user from terminating your app.Otherwise your app has a change to not get into the Store.

更多推荐

本文发布于:2023-08-06 22:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1456576.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   异常   Custom   exception   handling

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!