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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 22:11:25  来源:igfitidea点击:

Looking for simple MVVM Light example

wpfmvvmmvvm-light

提问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

I have found this example helpful:

我发现这个例子很有帮助:

http://apuntanotas.codeplex.com/

http://apuntanotas.codeplex.com/

回答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:

您可能会发现这些其他问题很有用:

mvvm light toolkit samples

mvvm light 工具包示例

wpf/silverlight mvvm sample app request

wpf/silverlight mvvm 示例应用程序请求

mvvm tutorial from start to finish

mvvm教程从头到尾

回答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:

我发现以下教程是一种快速简便的入门方法:

MVVM Light Toolkit Example

MVVM Light 工具包示例

MVVM Step By Step

MVVM 一步一步