C# 在类库中使用Caliburn Micro

C# 在类库中使用Caliburn Micro,c#,wpf,caliburn.micro,C#,Wpf,Caliburn.micro,我有一个类库,其中包含几个用户控件。此库使用caliburn micro在同一类库中使用x:Name方法将UserControls绑定到相应的ViewModels 现在我有了一个宿主应用程序,它在窗口中宿主这些用户控件。但是这个主机应用程序根本不使用Caliburn Micro。那么如何在库中初始化caliburn引导程序呢 主机应用程序: <Window> <ContentControl> <library:MainUserCont

我有一个类库,其中包含几个用户控件。此库使用caliburn micro在同一类库中使用
x:Name
方法将
UserControl
s绑定到相应的
ViewModels

现在我有了一个宿主应用程序,它在窗口中宿主这些用户控件。但是这个主机应用程序根本不使用Caliburn Micro。那么如何在库中初始化caliburn引导程序呢

主机应用程序:

<Window>       
  <ContentControl>
       <library:MainUserControl DataContext="{Binding MainUserControlViewModel}"/>
  </ContentControl>
</Window>
引导数据库覆盖

 public class AppBootstrapper : BootstrapperBase
    {
        public AppBootstrapper():base(false)
        {
        }
    }

我还尝试运行caliburn调试器,但在我的输出窗口中没有显示任何内容。

将caliburn.Micro mantainers和Andy Race提到的调试器放在一起,似乎在某种程度上是可行的,但客户端应用程序代码仍然需要引用CM

除了其他需要的设置(请参阅参考资料)外,约束是由于自定义控件视图模型如何绑定到XAML中所述的视图:唯一的方法是通过
cal:Bind.model
显式设置视图模型

。。。
xmlns:controls=“clr命名空间:Control.Library;assembly=Control.Library”
...
对于其余部分,客户端应用程序可以完全忽略Caliburn.Micro

public MainUserControlViewModel()
{            
     AppBootstrapper appBootstrapper = new AppBootstrapper();
     appBootstrapper.Initialize();
     if (Debugger.IsAttached)
            LogManager.GetLog = type => new DebugLog(type);            
}
 public class AppBootstrapper : BootstrapperBase
    {
        public AppBootstrapper():base(false)
        {
        }
    }