PhoneApplicationFrame rootFrame = (Application.Current as App).RootFrame;
rootFrame.Obscured += OnObscured;
rootFrame.Unobscured += Unobscured;
我在应用程序类的app()构造函数中编写此代码,但收到错误 - 无法使用实例引用访问成员'LockscreenNotification.App.RootFrame.get',而是使用类型名称限定它。
答案 0 :(得分:0)
我遇到了同样的问题。我修好了这个:
PhoneApplicationFrame rootFrame = App.Current.RootVisual as PhoneApplicationFrame;
if (rootFrame != null)
{
rootFrame.Obscured += OnObscured;
rootFrame.Unobscured += OnUnobscured;
}