문제

In windows phone 7, I'm using PhoneApplicationFrame to get the main frame as follows:

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

but the frame still null .. why?

도움이 되었습니까?

해결책

This was called in the MainPage constructor... At that time the application frame is not loaded yet. this cause the frame to be null

The solution is to create the frame in loaded event handler of the application

다른 팁

You need to do something like this:

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

Something similar was asked already here.

private PhoneApplicationFrame frame = (PhoneApplicationFrame)Application.Current.RootVisual;

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top