Alex Nicholas
Alex Nicholas

Reputation: 352

Caliburn Micro is not automatically wiring up my views to view models

I am fairly new to WPF, well - to be truthful - development in general. I've been at it for about 6 or 7 months now. I finished my first application, a basic customer management system that keeps records of customers, products, bookings, discounts etc... all functioning well however now comes the task of turning what is a fairly hacked together project into a well structured, cleanly coded application. The main part of this is adhering to the MVVM design pattern. After seeing the work involved to make the modification, I have decided a rewrite is a better option. I've started a new solution, added references to Caliburn Micro, brought all my models in from my previous project after some refactoring and removing unnecessary code from them.

The crux of my problem however is that Caliburn seems to not be doing what it is intended to do. I have folders in my root folder 'Views' and 'ViewModels' in which I have for example 'CustomersView.xaml' and a corresponding 'CustomersViewModel.cs'. None of my views are being married up to their ViewModel, and even if I declaratively set the DataContext through XAML in the View or set it in the code behind I still have to manually bind all the controls in the view to their property or action in the ViewModel.

I have searched online for a couple of days now and pretty much everything I've read tells me that this should be an automatic process and all that is required of me is that I implement the proper naming conventions which I have done.

Can anyone give me any direction in where to look for a solution. It seems that documentation on Caliburn is a little skint at best.

I'm away from my work machine at the moment however I think considering this is global throughout my project I seeing a snippet of the View and ViewModel would be a little meaningless (although I am happy to stand corrected)

Demonstration projects using Caliburn.Micro work fine and I am able to create new views and viewmodels and have them marry up...

Happy to hear any suggestions.

Upvotes: 0

Views: 750

Answers (1)

Lin Song Yang
Lin Song Yang

Reputation: 1944

Caliburn Micro looks the x:Class name in xaml file for the view to match the viewModel, ie the code behind class name and the x:Class name are used by Caliburn Micro to look up the view for the view model.

Upvotes: 2

Related Questions