4.关于子视图, MVVMLight Using Two Views:http://www.codeproject.com/Articles/323187/MVVMLight-Using-Two-Views

3.这篇讲的不错:MVVM、MVVMLight、MVVMLight Toolkit之我见

2.using the code snippet:

a.in Visual Studio, in the code behind file, MainViewModel.cs, enter the letters mvvminpc and press tab.  This will expand to a property, and by using tab you can set the property name to Customers and the backing variable to _customers.

1.使用教程:(WPFS) MVVM Light Toolkit: Soup To Nuts  Part

http://jesseliberty.com/2011/01/05/windows-phone-from-scratch-mvvm-light-toolkit-soup-to-nuts-part-2/ 中使用了

            <Button x:Name="Page2Button" Content="Page 2">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<Command:EventToCommand x:Name="Page2ButtonClicked" Command="{Binding Page2Command, Mode=OneWay}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>

但我发现,直接使用Command也有一样的效果:

 <Button Command="{Binding Page2Command, Mode=OneWay}" Content="try easy"></Button>

对于这一点,文章下面也讨论了:

Dave T says:

Actually that does seem to me like a valid question. The Command property is supported on Button both in Silverlight 4 and Windows Phone 7.1.

http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.buttonbase.command(v=VS.95).aspx

Chris Andritzky says:

Now I got it: It’s because in Silverlight there is no Button.Command property. It’s only available in WPF.

  • Rod Falanga says:

    Chris, if I’m understanding you correctly, you’re saying that if one were using WPF, all they’d have to do is something like this:

    am I correct?

  • Rod Falanga says:

    Chris, et. al, I’ve got another question concerning the Command property.  I’ve checked and found that with the release of Silverlight 4, it supports the Command property on the ButtonBase class (from Tim Heuer’s blog).  So then, I’m kind of confused as to what the need is to go through connecting a command using behaviors.  Why not just use the Command property of the button class?

Chris Andritzky says:

I don’t see why we need the EventToCommand behavior here. Why not just simply bind the Button.Command property to Page2Command? This would also ensure that the button gets disabled when the command’s CanExecuteChanged method returns false.

I see that this is only an example, but it might be better to use an event for which there is no corresponding Command property (like ComboBox. SelectionChanged).

MVVM Light 笔记的更多相关文章

  1. MVVM Light 笔记 - snippet

    RelayCommand有8个,看似很多,其实就是几个变化的组合: 1.是否Generic 2. 执行是使用lambda表达式还是method 3.是否有CanExecute 这些都在源代码Snipp ...

  2. 【MVVM Light】Messager的使用

    一.前言       在MVVM编程的模式中,有时候我们会遇到一个很尴尬的情况: 若干个xaml.cs都复用一个ViewModel,当ViewModel想传递一个特定的消息给某一个xaml.cs的时候 ...

  3. 【MVVM Light】新手初识MVVM,你一看就会

    一.前言 作为一个初入软件业的新手,各种设计模式与框架对我是眼花缭乱的.所以当我接触到这些新知识的时候就希望自己能总结几个步骤,以便更好更方便的在日常工作中进行使用. MVVM顾名思义就是Model- ...

  4. MVVM Light中的Message

    比喻:像漂流瓶一样发送一个Message,任何人有兴趣就可以拾起来. MVVM Light中的Message的使用分为三个步骤: 1.创建一个类,包含要传递的Message. 2.在ViewModel ...

  5. MVVM学习笔记

    MVVM学习笔记 1.MVVM的简介 MVVM模式是Model-View-ViewModel模式的简称,也就是由模型(Model).视图(View).视图模型(ViewModel),其目的是为了实现将 ...

  6. MVVM Light 一个窗口承载两个视图

    MVVM Light 一个窗口承载两个视图   原文地址:http://www.codeproject.com/Articles/323187/MVVMLight-Using-Two-Views 本文 ...

  7. Mvvm Light Toolkit for WPF/Silverlight系列之搭建mvvmlight开发框架

    Mvvm Light Toolkit for WPF/Silverlight系列之搭建mvvmlight开发框架   本章节,我将通过示例介绍如何搭建mvvmlight开发环境.示例中的我会针对wpf ...

  8. MVVM Light须要注意的10个问题

    MVVM Light须要注意的10个问题 从使用XAML技术基础開始(实际上并非非常久曾经).我便关注MVVM(Model – View – ViewModel)模式.偶然接触到MVVM Light不 ...

  9. MVVM Light 新手入门(1):准备阶段

    1.新建WPF空白项目. 2.NuGet 程序包中安装 3.根据MVVM分层结构,建立包含Model.View.ViewModel三层文件夹 如图: 1.View负责前端展示,与ViewModel进行 ...

随机推荐

  1. angularjs 粘贴事件

    参考 http://www.jb51.net/article/89708.htm ng-paste 需要setTimeout,否则无法获取到数据

  2. 【Spider】使用CrawlSpider进行爬虫时,无法爬取数据,运行后很快结束,但没有报错

    在学习<python爬虫开发与项目实践>的时候有一个关于CrawlSpider的例子,当我在运行时发现,没有爬取到任何数据,以下是我敲的源代码:import scrapyfrom UseS ...

  3. 齐博CMS:最常用的一些变量名,方便二次开发.必须要熟悉的

    ROOT_PATH程序所在硬盘目录的绝对地址,等同于以前的PHP168_PATH$webdb网站的全局变量,模块的全局变量也是这个$onlineip当前用户的IP$timestamp当前时间$WEBU ...

  4. java集合: LinkedList源码浅析

    LinkedList 数据结构是双向链表,插入删除比较方便.LinkedList 是线程不安全的,允许元素为null  . 构造函数: 构造函数是空的. /** * Constructs an emp ...

  5. pta l3-3(社交集群)

    题目链接:https://pintia.cn/problem-sets/994805046380707840/problems/994805053141925888 题意:给定n个人,以及每个人的兴趣 ...

  6. 前端、数据库、Django简单的练习

    一.前端 1.前端页面由哪几层构成,分别是什么,作用是什么? 分为:结构层(html),表示层(css),行为层(js). 结构层 超文本标记语言.由HTML或XHTML之类的标记语言负责创建.标签, ...

  7. 微信小程序template模板与component组件的区别和使用

    前言: 除了component,微信小程序中还有另一种组件化你的方式template模板,这两者之间的区别是,template主要是展示,方法则需要在调用的页面中定义.而component组件则有自己 ...

  8. 计算Python运行时间

    可以调用datetime 或者 time库实现得到Python运行时间 方法1 import datetime start_t  = datetime.datetime.now() #运行大型代码 e ...

  9. 41-ssm中对象查找正确但是没有将数据库中某个属性值赋给对象的一个成员变量

    原因: 变量名虽然与 数据库字段一致,但是 包含下划线,如: a_b,数据库确实也是a_b: 但是ssm开启驼峰命名了,就要将变量名改为   aB , 驼峰命名就可以了.

  10. 统计sql

    查询统计信息 select * from user_tab_statistics t where t.TABLE_NAME=upper('tablename'); 查询表基本信息 select * f ...