Search code examples
windows-phone-7windows-phone-7.1windows-phone-7-emulator

PhoneApplicationFrame is null in WP7


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?


Solution

  • 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