【发布时间】:2016-01-20 16:34:52
【问题描述】:
我有一个包含多个用户控件的类库。该库使用 caliburn micro 将UserControls 绑定到它们对应的ViewModels,使用同一类库中的x:Name 方法。
现在我有一个宿主应用程序,它将这些用户控件托管在一个窗口中。但是这个主机应用程序根本不使用 Caliburn Micro。那么如何在库本身中初始化 caliburn 引导程序。
主机应用程序:
<Window>
<ContentControl>
<library:MainUserControl DataContext="{Binding MainUserControlViewModel}"/>
</ContentControl>
</Window>
类库
<UserControl x:Class="MainUserControl">
<ContentControl x:Name="OtherUserControlInSameLibrary"/>
</UserControl>
我尝试继承像AppBootstrapper: Bootstrapperbase 这样的引导程序基类并将false 传递给构造函数参数useApplication。然后我调用了Initialize() 方法。但是仍然没有应用约定。
MainUserControlViewModel 构造函数
public MainUserControlViewModel()
{
AppBootstrapper appBootstrapper = new AppBootstrapper();
appBootstrapper.Initialize();
if (Debugger.IsAttached)
LogManager.GetLog = type => new DebugLog(type);
}
BootstrapperBase 覆盖
public class AppBootstrapper : BootstrapperBase
{
public AppBootstrapper():base(false)
{
}
}
我也尝试运行 caliburn 调试器,但我的输出窗口中没有显示任何内容。
【问题讨论】:
标签: c# wpf caliburn.micro