引言

接下来的是Commanding Demo的改造.

DelegateCommand

   WPF本身提供了一个RoutedCommand,然而没什么卵用.在Prism框架中提供了个更人性化的ICommand的实现--DelegateCommand,如下

public class ArticleViewModel : NotificationObject
{
private readonly ICommand showArticleListCommand; public ArticleViewModel(INewsFeedService newsFeedService,
IRegionManager regionManager,
IEventAggregator eventAggregator)
{
this.showArticleListCommand = new DelegateCommand(this.ShowArticleList);
} public ICommand ShowArticleListCommand
{
get { return this.showArticleListCommand; }
}
}

CompositeCommand

CompositeCommand是Prism提供的一个组合式命令实现.它可以在子命令都可用的情况下同时执行多个子命令.应用情况不是很多,但是可以了解一下.如下

public class MyViewModel : NotificationObject
{
private readonly CompositeCommand saveAllCommand; public ArticleViewModel(INewsFeedService newsFeedService,
IRegionManager regionManager,
IEventAggregator eventAggregator)
{
this.saveAllCommand = new CompositeCommand();
this.saveAllCommand.RegisterCommand(new SaveProductsCommand());
this.saveAllCommand.RegisterCommand(new SaveOrdersCommand());
} public ICommand SaveAllCommand
{
get { return this.saveAllCommand; }
}
}

示例源码

http://pan.baidu.com/s/1sjuWkod

小结

更多的Commandi用法可以在官方文档Prism 4.0的Chapter 9中查阅.

【Prism】MEF版Commanding的更多相关文章

  1. Prism&MEF构建开发框架 (一)

    Shell框架XECA shell.xaml主要起到是一个容器或壳的作用 <Window x:Class="XECA.Shell"      xmlns="http ...

  2. 【Prism】MEF版HelloWorld

    引言 Pirsm框架是由微软P & P小组设计的,用于构建组合式的WPF企业级应用,支持两个IOC容器,分别为Unity和MEF.官方地址为http://compositewpf.codepl ...

  3. 【Prism】MEF版UIComposition

    引言 UIComposition原版Demo在PrismV5的解压包里面.原Demo用了.net4.5版本的DLL,我改成.net4.0的. RegionContext 这个Demo比之前那几个示例大 ...

  4. 【Prism】MEF版EventAggregation

    引言 第三弹是EventAggregation Demo的改造. EventAggregation  EventAggregation事件聚集是Prism框架中的通信实现.它可以在松散的模块或者窗体之 ...

  5. Prism&MEF构建开发框架 (三)

    菜单管控模块EntityFW 菜单的加载采用MEF技术,程序实现思路: 1 .主菜单加载页面MainMenuView.xaml指向MenuRegion 2. 菜单Item点击及内容加载,采用订阅模式, ...

  6. 一步步实现 Prism + MEF(一)--- 搭建框架

    第一步:构建一个名为Bootstrapper的类作为引导程序. class Bootstrapper : MefBootstrapper { } 第二步:在MainWindow窗体中添加一个Coont ...

  7. Prism MEF example

    Related Attributes These attributes are under namespace System.ComponentModel.Composition Import The ...

  8. 一步步实现 Prism + MEF(二)--- 绑定命令

    Prism程序集为我们提供了DelegateCommand命令,使用该命令可实现窗口直接绑定.第一步:在ViewModel中定义一个DelegateCommand属性. public Delegate ...

  9. Prism&MEF构建开发框架

    系统框架构想效果图 平台简单由左侧菜单和右侧内容区以及顶部系统和用户信息区构成 菜单根据系统模块动态加载 右侧,根据左侧选中菜单动态加载子模块,子模块集合以tab选项卡方式布局 系统模块划分为Shel ...

随机推荐

  1. attention机制七搞八搞

    注意力机制即Attention mechanism在序列学习任务上具有巨大的提升作用,在编解码器框架内,通过在编码段加入A模型,对源数据序列进行数据加权变换,或者在解码端引入A模型,对目标数据进行加权 ...

  2. F110 BADI增强

    F110*JOB*&------------------------------------------------------------- F110 BADI FI_BSTM_MC_EXI ...

  3. 学习OpenCV2——Mat之通道的理解

    本文详细介绍了opencv中涉及通道的知识,包括图像类型转换,通道合成分解,图像的显示. 来源:http://blog.csdn.net/GDFSG/article/details/50927257 ...

  4. 8.22 ps课堂练习

    真是做得超烂!以前学的快忘光了!

  5. 【HackerRank】Service Lane

     Calvin is driving his favorite vehicle on the 101 freeway. He notices that the check engine light o ...

  6. 【leetcode刷题笔记】Multiply Strings

    Given two numbers represented as strings, return multiplication of the numbers as a string. Note: Th ...

  7. ubuntu里设置从串口登录

    1) Create a file called /etc/init/ttyS0.conf containing the following: # ttySAC0 - getty # # This se ...

  8. Delphi 2005 以上版本GIF动画播放设置

    源: Delphi 2005 以上版本GIF动画播放设置

  9. python对象类型----数字&字符串

    一数据类型:      float: 1.3e-3  1.3*10的负三次方 print (1.3e-3)    bin()  #转换为二进进制    oct() #转换为8进制    hex()#转 ...

  10. Docker容器技术-Docker架构

    一.Docker系统架构 1.Docker基础架构 1)Docker守护进程 负责容器的创建.运行和监控,以及镜像的构建和存储. docker daemon 2)Docker客户端 通过HTTP与Do ...