windows phone 访问根框架以处理被遮挡的事件

windows phone access rootframe to handle obscured event

我正在尝试访问 windows phone 的模糊事件,为此我需要访问根框架。我正在开发 windows phone silverlight 8.1 应用程序。我的代码是:

public MainPage()
    {
        InitializeComponent();

        (Application.Current as App).RootFrame.Obscured += OnObscured;
        (Application.Current as App).RootFrame.Unobscured += OnUnobscured;
    }

上面的代码给出了一个错误“'calltest.App.RootFrame.get' 不能用实例引用访问;用类型名称限定它”。怎么了?

RootFrame 是静态的,因此请将您的代码替换为:

App.RootFrame.Obscured += OnObscured;
App.RootFrame.Unobscured += OnUnobscured;