windows phone访问rootframe来处理模糊事件

时间:2015-10-21 08:57:52

标签: c# silverlight windows-phone

我正在尝试访问Windows Phone的模糊事件,因为我需要访问rootframe。我正在开发一款Windows phone Silverlight 8.1 app。我的代码是:

public MainPage()
    {
        InitializeComponent();

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

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

1 个答案:

答案 0 :(得分:2)

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

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