Cannot get this to work from the start

Apr 11, 2012 at 6:50 AM

I created a project named Jaws.Client from the WPF Catel 3.0.1 template. I added references to the libraries. I created a new WPF Catel UserControl View(UserControl1) and a new Catel View Model (UserControl1ViewModel). I compiled the app and then I added the user control to the MainWindow View. When I run the app I get this error:


'The invocation of the constructor on type 'Jaws.Client.Views.UserControl1' that matches the specified binding constraints threw an exception.' Line number '22' and line position '10'.


{"The view model of the view could not be resolved. Use either the GetViewModelType() method or IViewModelLocator"}

This is really frustraiting me and I was super excited to use this but I don't understand what I'm doing wrong. I've read through the docs here and there and searched this discussion alias. I've looked at the existing examples and I don't know what I'm missing. I'm wasting hours on this. I'm just about to just go to something like MVVM Light because it just works right away. Please help.

Apr 11, 2012 at 7:31 AM

No worries, this can be fixed in a breeze. Here is the full documentation. The issue is that your views and view models apparently do not follow the naming conventions.

Short description, you have 3 options:

1) Override GetViewModelType on the user control (just like the exception tells you) <== this is the easiest and fastest way

2) Register the custom view model once using the ViewModelLocator.Register

3) Customize the naming conventions in the ViewModelLocator <== better if you use a custom naming convention in your whole app

I don't know how this can take hours, the exception is pretty clear, don;'t you think?

Apr 11, 2012 at 5:26 PM

Thanks for that link. I found that info after I posted. I was assuming there was auto resolving going on. The exception doesn't tell me what it was looking for and not finding, it just gives me an alternative. But I want it to work the way it should work :)

Apr 11, 2012 at 5:27 PM

So, issue solved?

Apr 11, 2012 at 5:34 PM

Well no :) I don't know why it isn't working. It seems like it should.

Apr 11, 2012 at 6:11 PM

Try creating a PersonControl in the Views folder, and a PersonViewModel in the view model folder. Should work out of the box. It's probably the 1 (at the end of UserControl1) that is ruining the game for you.

Apr 11, 2012 at 6:47 PM

Ack yes that was it. Thank you for your support!

May I suggest that the documentation that you linked to me introduce what the default is before discussing customizing it? Having the default after customization feels like an illogical choice. I think it's better to introduce something, explain how it works by default, then go into customizing it.

Additionally the getting started section of the documentation doesn't feel like "getting started" in the traditional sense. It feels more like a "How to setup a project to work with Catel" tutorial. I went to getting started to become (as your getting started introduction says) "acquainted with Catel". But there is no flow of where I should go next in the documentation.

Hope my feedback helps! Thanks again for your support.

Apr 12, 2012 at 7:47 AM

Thanks for the feedback, we will try to improve the docs in the future.

May 26, 2012 at 6:01 PM

So, we finally found time to completely rewrite the getting started docs. You can find them here, hopefully you like it more: