找不到ViewModel的视图 [英] Cannot find view for ViewModel

查看:232
本文介绍了找不到ViewModel的视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Caliburn.Micro的wpf应用程序。我有一个MyView视图:

I have a wpf application using Caliburn.Micro. I have a view MyView:

<UserControl x:Class="ReferenceMaintenanceWorkspace.MyView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         >
  <UserControl.Resources>
 </UserControl.Resources>
 <TabControl x:Name="Items" > 
</TabControl>

我也有MyViewModel:

I have also MyViewModel:

using System.ComponentModel.Composition;

namespace ReferenceMaintenanceWorkspace
{
[Export(typeof(MyViewModel))]
public class MyViewModel
{
  public MyViewModel()
  {
      base.DisplayName = "Reference Maintenance";
  }

由于某些原因,我在选项卡控件上收到以下消息:

Because of some reason, I get the following message on the tab control:

找不到ReferenceMaintenanceWorkspace.MyViewModel的视图。

Cannot find view for ReferenceMaintenanceWorkspace.MyViewModel.

您能解释一下为什么会发生这种情况吗?
谢谢。

Could you please explain why this could happen? Thanks.

推荐答案

Caliburn Micro期望项目中的某些文件结构。您的视图和视图模型应该位于名为视图和视图模型的单独文件夹中。

Caliburn Micro is expecting certain file structure within your project. Your views and viewmodels should be in separate folders named Views and ViewModels.

此处是一个很好的Hello World示例,描述了这一点。

Here is a nice Hello World example that describes this.

这篇关于找不到ViewModel的视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆