寻找简单的 MVVM Light 示例

发布于 2024-09-25 13:10:45 字数 192 浏览 0 评论 0原文

我正在尝试学习 MVVM Light,并正在寻找一个很好的基本示例来显示模型以及如何加载不同的视图。

我下载 MVVM Light 后看到的模板没有模型,只有一个视图。 (http://www.galasoft.ch/mvvm/creating/)

当我只想看到基础知识时,我发现其他事情更加复杂并且有点令人困惑。

谢谢。

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.

The template I see after downloading MVVM Light has no models and only one view. (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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

泪冰清 2024-10-02 13:10:45

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

http://apuntanotas.codeplex.com/

I have found this example helpful:

http://apuntanotas.codeplex.com/

才能让你更想念 2024-10-02 13:10:45

我个人发现这些非常有用,尽管它们也使用 MEF 和 RIA 服务,这可能会使事情变得复杂:

使用 MEF、MVVM 和 WCF RIA 服务的示例 Silverlight 4 应用程序

使用 RIA 服务 MEF 和 MVVM 构建 Silverlight 4 - 第 1 部分

4 月份,MVVM Light 工具包的作者表示,他最终将在 Silverlight 和 WPF 中创建参考应用程序。 (来源)

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

mvvm light 工具包示例

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

mvvm 教程从头到尾

I have personally found these to be quite useful, though they also use MEF and RIA Services which can complicate things:

A Sample Silverlight 4 Application Using MEF, MVVM, and WCF RIA Services

Architecting Silverlight 4 with RIA Services MEF and MVVM - Part 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)

You might find these other questions useful:

mvvm light toolkit samples

wpf/silverlight mvvm sample app request

mvvm tutorial from start to finish

深空失忆 2024-10-02 13:10:45

我发现这两个非常有帮助:

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 第一个只是 MVVM Light 的一个简单的嵌入式 viewModelLocator 类,为您提供 MEF 功能。

[ExportViewModel("Demo1", false)]
class Demo1ViewModel : ViewModel
{   
}

第二个,使用与附加 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);
}

I found these two to be very helpful:

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 first one is just a simple drop-in viewModelLocator class for MVVM Light that gives you the MEF abilities.

[ExportViewModel("Demo1", false)]
class Demo1ViewModel : ViewModel
{   
}

And the second one, uses the same approach with an additional MefHelper class that enables run time loading of MEF components.

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);
}
殊姿 2024-10-02 13:10:45

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

MVVM Light Toolkit 示例

MVVM 一步一步

I found the following tutorials to be a quick and easy way to get started:

MVVM Light Toolkit Example

MVVM Step By Step

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文