C# windows phone访问根框架以处理隐藏事件

C# windows phone访问根框架以处理隐藏事件,c#,silverlight,windows-phone,C#,Silverlight,Windows Phone,我正在尝试访问windows phone的隐藏事件,为此我需要访问根框架。我正在使用windows phone silverlight 8.1应用程序。我的代码是: public MainPage() { InitializeComponent(); (Application.Current as App).RootFrame.Obscured += OnObscured; (Application.Current as App).Roo

我正在尝试访问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;