fussmonkey
fussmonkey

Reputation: 678

Caliburn.Micro display external UserControl

I'm trying to create a new WPF application using Caliburn.Micro. I have a View where I'd like to display a UserControl from an external assembly that is not following MVVM.

I tried creating a ContentControl on my View, and in the ViewModel I have a property that returns the type of the external usercontrol.

<ContentControl Name="SqlConnectLabel" Content="{Binding}" />

and

public sql.ConnectLabel SqlConnectLabel
{
  get { return p_oConnectLabel; }
  set
  {
    p_oConnectLabel = value;
    NotifyOfPropertyChange(() => SqlConnectLabel);
  }
}

When I run my application, the ContentControl displays "Cannot find view for [Namespace of external UserControl]."

Is there a way to display an external, non-MVVM UserControl like that on a View?

Upvotes: 0

Views: 243

Answers (2)

Charleh
Charleh

Reputation: 14012

You can just add it to the design surface or XAML as a standard UserControl (since you don't need CM to bind it all up)

Obviously if you are resolving the view at runtime then a different approach is needed, but otherwise, drag and drop!

Upvotes: 2

McDonnellDean
McDonnellDean

Reputation: 1087

Dropping it on as a normal UserControl would be the safest option. In general if it was not built with a MVVM in mind it will be a pain to bind to (Lack of INPC for instance).

Upvotes: 2

Related Questions