ViewModels are not attached automatically

Topics: Bootstrappers & IoC, Bugs
Dec 17, 2013 at 10:39 PM
Good day.
Some of my ViewModels are not attached to views automatically. I use proper naming convention and declare those VMs using PerRequest, so, the usual stuff. But they are not attached to corresponding views even if navigationService recognizes them with no problem. Some weird magic is going on, because, as I said, I have this issue not with all VMs.
Dec 18, 2013 at 2:42 AM
can you give us an idea what you are seeing? Code / ScreenShot etc...
Dec 18, 2013 at 8:18 AM
Edited Dec 18, 2013 at 8:22 AM
File tree looks like this:

-- MainPageViewModel.cs
-- News/
---- NewsDetailsPageViewModel.cs
-- Machines/
---- MachineSearchPageViewModel.cs
-- MainPage.xaml
-- News/
---- NewsDetailsPage.xaml
-- Machines/
---- MachineSearchPage.xaml

Main page and news details page are being attached with VMs with no problem. With machine search I had to use DataContext = new MachineSearchPageViewModel(). All VMs inherit Screen and CM version is 1.5.2.

The Configure() section of my Bootstrapper.cs:
Dec 18, 2013 at 6:07 PM
I managed to make Machine Search Page work by recreating it within Views|ViewModels/ instead of Views|ViewModels/Machines.
Dec 24, 2013 at 2:40 PM
Could you please address this issue? It's a blocker for me.
Dec 25, 2013 at 1:39 AM
Did you make any changes or add anything to the NamingConvention?
Jan 2, 2014 at 4:30 PM
Edited Jan 2, 2014 at 4:30 PM
Nekroido, the only default naming convention is for mapping between the *.ViewModel and *.View namespaces. It's not based on the directory structure, as the namespace in a given file can differ from its location in the directory hierarchy. I think you'll either need to change the namespaces in your News and Machines views and viewmodels to be Views.{NewsDetailsPage|MachineSearchPage}View and ViewModels.{NewsDetailsPageViewModel|MachineSearchPageViewModel}, respectively, or set up a custom naming convention (my recommendation). Here is some relevant documentation on that:
Hope this helps.

Jan 2, 2014 at 4:38 PM
Perhaps Nekroido, you could write the full name (Namespace + class name, not file location) of the views and the view-models - This will enable everyone to see what's going on :)

Good luck!