English 中文(简体)
页: 1 支持服务的任何组成部分}
原标题:Caliburn Micro and Windsor Castle Boostraper { No component for supporting the service }

Hi I试图使用Caliburn微粒的温斯尔堡。 直到现在,我只使用最低生活标准。

页: 1

我在我的项目中添加了这一呼吁,并修改了Appxaml档案:

<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>

我制造壳牌书和壳牌文View:

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>();

In MEF 用户称号:[Export][Import].。 谁能领导我处理这个问题?

Another question is that I have some tool class:

public interface ITooll{}

public class Tool:ITool{}

我愿在壳牌照的“Model”类中进口。

How can I do it with with CastleBoostraper?

问题回答

You need to register your view models and views in the container. The older Windsor version worked based on attributes, but on latest version you can do this with the fluent API or even bulk register based on some convention:

public class Bootstrapper : Bootstrapper<IShellViewModel>
{
    protected override IServiceLocator CreateContainer()
    {
        _container = new WindsorContainer();
        var adapter = new WindsorAdapter(_container);
        _container.Register(Component.For<ITool>().ImplementedBy<Tool>().LifeStyle.Transient);

        return adapter;
    }
}

你们也能够创造力。 将在集装箱内登记类型,因此,你的诱杀手法不会最终形成许多登记法:

public class ShellRegistration : IWindsorInstaller
{
    public void Install(IWindsorContainer container, IConfigurationStore store)
    {
        container.Register(Component.For<ITool>().ImplementedBy<Tool>().LifeStyle.Transient);
        //Register other types
    }
}

并把它放在boot锁中:

public class Bootstrapper : Bootstrapper<IShellViewModel>
{
    protected override IServiceLocator CreateContainer()
    {
        _container = new WindsorContainer();
        var adapter = new WindsorAdapter(_container);
        _container.Install(FromAssembly.This());

        return adapter;
    }
}

http://docs.courtproject.org/Windsor.Silvertlight_Sample_App_Customer_contact_manager.ashx”rel=“nofollow”> 我创立了寻找如何与温莎堡合作的方法。

你们能够利用信使注射或财产注入,了解你们的依赖情况:

public class ShellViewModel
{
    public ShellViewModel(IMyDependency dependency)
    {
       //you ll get an instance of the class implementing IMyDependency
       //Logger property will be injected after construction
    }

    public ILog Logger
    {
        get; set;
    }
}




相关问题
WPF convert 2d mouse click into 3d space

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

WPF: writing smoke tests using ViewModels

I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

How do WPF Markup Extensions raise compile errors?

Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签