wpf 寻找简单的 MVVM Light 示例
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3848375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Looking for simple MVVM Light example
提问by BillyPilgrim
I'm trying to learn MVVM Light and am looking for a good basic example that shows a model and how to load different views.
我正在尝试学习 MVVM Light,并且正在寻找一个很好的基本示例来展示模型以及如何加载不同的视图。
The template I see after downloading MVVM Light has no models and only one view. (http://www.galasoft.ch/mvvm/creating/)
我下载MVVM Light后看到的模板没有模型,只有一个视图。(http://www.galasoft.ch/mvvm/creating/)
Other things I've found are more complex and a bit confusing when all I want to see are the basics.
当我只想看到基础知识时,我发现的其他事情更复杂且有点混乱。
Thanks.
谢谢。
采纳答案by Bill
回答by kevev22
I have personally found these to be quite useful, though they also use MEF and RIA Services which can complicate things:
我个人发现这些非常有用,尽管它们也使用 MEF 和 RIA 服务,这会使事情变得复杂:
A Sample Silverlight 4 Application Using MEF, MVVM, and WCF RIA Services
使用 MEF、MVVM 和 WCF RIA 服务的示例 Silverlight 4 应用程序
Architecting Silverlight 4 with RIA Services MEF and MVVM - Part 1
使用 RIA 服务 MEF 和 MVVM 构建 Silverlight 4 - 第 1 部分
In April, the author of the MVVM Light toolkit said that he would eventually be creating a reference application in both Silverlight and WPF. (Source)
4 月份,MVVM Light 工具包的作者表示他最终将在 Silverlight 和 WPF 中创建一个参考应用程序。(来源)
You might find these other questions useful:
您可能会发现这些其他问题很有用:
wpf/silverlight mvvm sample app request
回答by kgrandpak
I found these two to be very helpful:
我发现这两个非常有帮助:
http://www.codeproject.com/KB/WPF/blendable_locator.aspxhttp://rickrat.wordpress.com/2011/01/24/using-mef-to-link-view-model-locator-and-load-assembly-uis-dynamically
http://www.codeproject.com/KB/WPF/blendable_locator.aspx http://rickrat.wordpress.com/2011/01/24/using-mef-to-link-view-model-locator-and-load -assembly-uis-dynamically
The firstone is just a simple drop-in viewModelLocator class for MVVM Light that gives you the MEF abilities.
在第一个只是一个简单的插入式viewModelLocator类MVVM光,让您的MEF能力。
[ExportViewModel("Demo1", false)]
class Demo1ViewModel : ViewModel
{
}
And the secondone, uses the same approach with an additional MefHelper class that enables run time loading of MEF components.
而第二一个,使用一个额外MefHelper类,使MEF组件的运行时间加载相同的方法。
public void Compose()
{
AggregateCatalog Catalog = new AggregateCatalog();
// Add This assembly's catalog parts
System.Reflection.Assembly ass = System.Reflection.Assembly.GetEntryAssembly();
Catalog.Catalogs.Add(new AssemblyCatalog(ass));
// Directory of catalog parts
if (System.IO.Directory.Exists(ExtensionsPath))
{
Catalog.Catalogs.Add(new DirectoryCatalog(ExtensionsPath));
string[] folders = System.IO.Directory.GetDirectories(ExtensionsPath);
foreach (string folder in folders)
{
Catalog.Catalogs.Add(new DirectoryCatalog(folder));
}
}
_Container = new CompositionContainer(Catalog);
}
回答by Eternal21
I found the following tutorials to be a quick and easy way to get started:
我发现以下教程是一种快速简便的入门方法: