0

I'm still experimenting a bit with Caliburn Micro and I can't seem to find a way to directly add a view to a xaml without adding another ContentControl with a property in the viewmodel behind it.

I can place this: <views:TheView ... /> in the xaml but then it can't find the target actions so it seems it doesn't find the viewmodel behind the view.

Is it possible to directly declare a view in a xaml without a ContentControl, and how?

The Cookies Dog
  • 1,915
  • 2
  • 22
  • 38

1 Answers1

0

You will have to tell Caliburn to bind the view model to a user control.

In the definition of "TheView" are you able to add the following line to the UserControl element:

cal:Bind.Model="TheViewModel"

So it will look similar to:

<UserControl  x:Class="Example.Views.TheView" 
              cal:Bind.Model="Example.ViewModels.TheViewModel" ...

While looking into this I did find this answer to another StackOverflow question: Does Caliburn.Micro play nicely with user controls?

Community
  • 1
  • 1
Nathan White
  • 173
  • 8