嗨,我尝试将 Windosor Castle 与 Caliburn Micro 一起使用。到目前为止,我只使用 MEF。
我发现了这个 Castle Boostraper:https ://gist.github.com/1127914
我将此调用添加到我的项目并修改了 App.xaml 文件:
<Application x:Class="Chroma_Configer.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Bootstraper="clr-namespace:Chroma_Configer.Bootstraper">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
<Bootstraper:CastleBootstrapper x:Key="bootstrapper" />
<Style x:Key="MainView_FontBaseStyle" TargetType="{x:Type Control}">
<Setter Property="FontFamily" Value="Arial"/>
</Style>
</ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
我创建 ShellView (WPF) 和 ShellViewModel:
public interface IShellViewModel
{
}
public class ShellViewModel : Conductor<IScreen>.Collection.OneActive,
IShellViewModel
{
}
当我运行时,我收到此错误:
{"No component for supporting the service Chroma_Configer.ViewModels.IShellViewModel was found"}
我是温莎城堡的初学者,我知道他的工作是这样的:
var container = new WindsorContainer();
container.AddComponent("JsonUtil", typeof(IShellViewModel), typeof(ShellViewModel));
var shell = container.Resolve<IShellViewModel>();
在 MEF 中,我使用属性[Export]和[Import]。有人可以帮我解决这个问题吗?
另一个问题是我有一些工具类:
public interface ITooll{}
public class Tool:ITool{}
我想在 ShellViewModel 类中导入它。
我如何使用 CastleBoostraper 来做到这一点?