caliburn.micro 如何为视图模型运行时加载和绑定视图
我正在构建一个需要主题支持的应用程序。所以我想提供视图文件夹运行时。
public class AppBootstrapper : Bootstrapper<IShell>
{
CompositionContainer _container;
/// <summary>
/// By default, we are configure to use MEF
/// </summary>
protected override void Configure()
{
//view locator code get views from file and and binding it to viewmodel run time.
}
}
I am building an application that requires theme support. So I want to supply views folder run time.
public class AppBootstrapper : Bootstrapper<IShell>
{
CompositionContainer _container;
/// <summary>
/// By default, we are configure to use MEF
/// </summary>
protected override void Configure()
{
//view locator code get views from file and and binding it to viewmodel run time.
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更好的调整是使用这种方式(在 Caliburn 中实现,但不在 Micro 中实现)。 http://caliburnmicro.codeplex.com/discussions/265502
首先,您需要定义一个用于存储用于发现视图的相关数据的属性:
将其附加到您的视图模型。
然后,您需要将引导程序中的 LocateTypeForModelType 更改为如下所示:
A better tweak would be to use this way (implemented in Caliburn but not the Micro one). http://caliburnmicro.codeplex.com/discussions/265502
First of all you need to define an attribute used to store the relevant data used to discover the view:
Attach it to your View Model.
Then, you need to change the LocateTypeForModelType in your bootstrapper to something like this:
在 Caliburn 中,您可以创建自定义的 IConventionManager 或调整实现 (DefaultConventionManager) 以更改框架在运行时查找 View 文件夹的方式。
事实上,视图不一定位于 Views 文件夹中,您可以修改此默认行为,因为这只是默认约定。实现此接口的最佳方法是检查默认实现。
In Caliburn, you can create a customized IConventionManager or tweek the implementation (DefaultConventionManager) to change the way the framework finds the View folder at runtime.
In fact views should not necessarily be in Views folder and you can modify this default behavior as this is just the default Convention. The best way to implement this interface is to check the default implementation.