c# - 找不到 View 模型的 View

标签 c# wpf mvvm caliburn.micro

我无法使用Caliburn.Micro找到任何 View 。 bootstrap 启动,但是随后出现一个通用窗口,即使存在 ShellView.xaml ,也没有 ShellViewModel的任何 View 。做什么?

bootstrap

public sealed class AppBootstrapper : BootstrapperBase
{


    private IKernel _kernel;

    #region Bootstrapper

    public AppBootstrapper()
    {
        Start();
    }

    protected override void Configure()
    {
        _kernel = new StandardKernel();
        _kernel.Bind<IWindowManager>().To<WindowManager>().InSingletonScope();
        _kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
        _kernel.Bind<IShell>().To<ShellViewModel>();
    }

    protected override void OnStartup(object sender, System.Windows.StartupEventArgs e)
    {
        DisplayRootViewFor(typeof (IShell));
    }

    protected override void OnExit(object sender, EventArgs e)
    {
        _kernel.Dispose();
        base.OnExit(sender, e);
    }

    protected override object GetInstance(Type serviceType, string key)
    {
        if (serviceType != null) {
            return _kernel.Get(serviceType);
        }

        throw new ArgumentNullException("serviceType");
    }

    protected override IEnumerable<object> GetAllInstances(Type serviceType)
    {
        return _kernel.GetAll(serviceType);
    }

    protected override void BuildUp(object instance)
    {
        _kernel.Inject(instance);
    }

    #endregion

    }
}

ShellViewModel
 public sealed class ShellViewModel : Screen, IShell
{

    public ShellViewModel()
    {
        DisplayName = "Hello";
    }

}

最佳答案

您可能需要使用SelectAssemblies的替代项来告诉CM“.dll”用于 View 和 View 模型的位置。否则,它将永远找不到它们。我通常也将其用于我的项目,它应该可以解决您的问题。

关于c# - 找不到 View 模型的 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22907879/

相关文章:

c# - 使用 LINQ 和 C# 的随机数组

c# - public T GetMyClass<T>() where T : MyClass, new() {/* 这是没有意义的吗? */}

c# - 如何访问正在呈现的 ListBox 中的项目而不是其源数据?

c# - WPF 中作用域 EF Core DbContext 的生命周期

wcf - MVVM 和 WPF - View 模型和模型关系

c# - 无法从 hMailServer 连接/发送

c# - 从其他ViewModel调用方法

.net - 在哪里可以找到一些 WPF 动画示例?

mvvm - 如何使用silverlight将xaml中的drageventArgs作为命令参数进行引用

c# - WPF 中的多拖放——示例/示例/教程?