Why MainPage.xaml can't be in the Views Namespace in WP7 Project?

Topics: Bootstrappers & IoC
Nov 20, 2012 at 1:31 AM

Excuse me, As the title Asked, if I put the MainPage.xaml Into the Views Namespace, When I Call the PreRequest<MainPageViewModel>() And After Initialized, it will throw a Exception.

If I put the MainPage.xaml Into the Top Namespace instead of Views.MainPage, it will be work.

The other page or views which put into the Views NameSpace will no occur this problem?

Nov 20, 2012 at 2:54 AM
Edited Nov 20, 2012 at 2:55 AM

MainPage was what the application was created with by default... Therefore in the WPAppManifest.xml file there is an entry that links the location of the MainPage.xaml to the root of the project.  Moving it causes issues :).  So just put "/Views/MainPage.xaml" as your startup location in the WPAppManifest.xml


      <DefaultTask Name="_default" NavigationPage="/Views/MainView.xaml" />

once you do this you should also change the namespace in the files too.. 

AppXX.Views.MainPage etc..  this also has to be done in the xaml view as well as the code behind.

I also assume that your viewmodel MainPageViewModel is located in a ViewModels folder?