c# - 事件支持 WP 8.1

标签 c# events exception runtime-error

我使用下面的代码来处理反压的事件,但它不起作用

 private void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
    {
        Frame frame = Window.Current.Content as Frame;
        if (frame == null)
        {
            return;
        }

        if (frame.CanGoBack)
        {
            frame.GoBack();
            e.Handled = true;
        }

它返回这个错误:

Error 1 The type or namespace name 'BackPressedEventArgs' could not be found (are you missing a using directive or an assembly reference?)

任何人都可以帮助我,或者指出正确的方向吗?

最佳答案

如果您尝试处理按下的特定键,您通常会收到所有这些事件作为单个 KeyPressed 事件或类似事件。

此外,在处理事件时,您实际上将处理程序添加到事件中,该事件有一个特定的委托(delegate),它应该为您指明正确的方向。

关于c# - 事件支持 WP 8.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29958070/

相关文章:

c# - 抛出异常时执行某事的最佳方式(模式)

python - 在循环中捕获异常回溯,然后在脚本末尾引发错误

c# - 尝试将重复项添加到集合时应该抛出什么异常类型?

C# ASP.NET ListView

c# - 如何使用 C# 在本地自动获取在线 HTML 表

events - 如何对事件循环进行单元测试?

java - Vaadin:带有表事件处理的选项卡

c++ - 如何将行号传递给异常?

c# - 将用户重定向到 Paypal 站点以及来自代码隐藏的编程数据

c# - 当它接收到新元素时,不断循环遍历线程中的列表