Windows phone 7 PhoneApplicationFrame在WP7中为空

Windows phone 7 PhoneApplicationFrame在WP7中为空,windows-phone-7,windows-phone-7.1,windows-phone-7-emulator,Windows Phone 7,Windows Phone 7.1,Windows Phone 7 Emulator,在windows phone 7中,我使用PhoneApplicationFrame获取主框架,如下所示: // set the main layout if (frame == null) { frame = Application.Current.RootVisual as PhoneApplicationFrame; } 但是帧仍然为空。。为什么?您需要这样做: var curren

在windows phone 7中,我使用PhoneApplicationFrame获取主框架,如下所示:

 // set the main layout
            if (frame == null)
            {
                frame = Application.Current.RootVisual as PhoneApplicationFrame;
            }

但是帧仍然为空。。为什么?

您需要这样做:

var currentPage = ((App)Application.Current).RootFrame.Content as PhoneApplicationPage;

类似的东西。

这是在主页构造函数中调用的。。。此时尚未加载应用程序帧。这将导致帧为空


解决方案是在应用程序的已加载事件处理程序中创建框架

私有PhoneApplicationFrame=(PhoneApplicationFrame)application.Current.RootVisual

你用什么方法/事件来做这件事?