Caliburn.Micro HelloWindowManager示例-视图位置不起作用 [英] Caliburn.Micro HelloWindowManager Sample - View location not working

查看:290
本文介绍了Caliburn.Micro HelloWindowManager示例-视图位置不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HelloWindowManager Caliburn.Micro示例演示了将窗口(视图)显示为模态,无模式或弹出窗口,并且工作正常.但是,它在项目根目录中具有视图和Viewmodels,因此我想对其进行整理,并使它对视图和视图模型位置使用默认约定,因此我进行了以下更改:

The HelloWindowManager Caliburn.Micro sample demonstrates displaying a Window (View) as Modal, Modeless or Popup and works just fine. However it has the views and Viewmodels in the project root so I wanted to tidy it up and have it use the default convention for view and view model locations, so I made the following changes:

  1. 创建了一个Views文件夹,并在其中移动了ShellView.xaml和DialogView.xaml
  2. 创建了一个ViewModels文件夹并移动了匹配的View Models
  3. 调整了4个文件中的名称空间以反映移动

现在,在运行修订后的示例时,我有一种奇怪的行为,即打开模态"按钮可以完美工作,从而表明可以找到VM的视图",无模式打开"和打开弹出窗口"按钮均会显示该消息. 找不到caliburn.Micro.HelloWindowmanager.ViewModels.DialogViewModel的视图"

On running the revised sample now I have the weird behaviour that while the 'Open Modal' button works perfectly, thus demonstrating that the View for the VM CAN be found, both the Open Modeless and the Open Popup buttons result in the message "Cannot find View for caliburn.Micro.HelloWindowmanager.ViewModels.DialogViewModel"

有什么想法吗?

编辑后添加:

在没有任何人回答的情况下,我修改了示例以使用SimpleContainer代替MEF-它显示的行为与上述完全相同.

Absent any answers from anyone, I modified the sample to use the SimpleContainer instead of MEF - and it displays exactly the same behaviour as above.

例如此调用有效:
var result = windowManager.ShowDialog(new DialogViewModel());

e.g. This call works:
var result = windowManager.ShowDialog(new DialogViewModel());

但是这两个调用导致出现找不到视图..."错误消息

but these two calls result in the 'cannot find view...' error message

windowManager.ShowWindow(new DialogViewModel(), "Modeless");

windowManager.ShowPopup(new DialogViewModel(), "Popup", settings);

windowManager.ShowPopup(new DialogViewModel(), "Popup", settings);

我应该以某种方式将DialogViewModel添加到SimpleContainer吗?

Should I somehow be adding DialogViewModel to the SimpleContainer?

推荐答案

很确定我的评论就是答案...

Pretty sure my comment is the answer...

在views文件夹中,您都需要一个名为Dialog的文件夹,您将在其中放置Modeless.xaml和Popup.xaml,这两个文件夹都需要分别具有例如".Views.Dialog.Modeless"作为其命名空间. .它是一个视位定位器演习,即使我也曾战斗过多次. :/

within the views folder you will all so need a folder called Dialog within that folder you will place Modeless.xaml and Popup.xaml both with of which need to have for example ".Views.Dialog.Modeless" as their namespace respectively. Its a viewlocator drill that even I have fought with many times. :/

注意:这只是语义,您可以直接在命名空间中放入不带文件夹的名称,但是从项目的组织结构中可以更好地理解它.

Note: This just semantics you could put in the Namespace directly without the folder but from an organizational structure of the project it helps to understand it better.

这篇关于Caliburn.Micro HelloWindowManager示例-视图位置不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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