【Prism】MEF版Commanding
引言
接下来的是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的更多相关文章
- Prism&MEF构建开发框架 (一)
Shell框架XECA shell.xaml主要起到是一个容器或壳的作用 <Window x:Class="XECA.Shell" xmlns="http ...
- 【Prism】MEF版HelloWorld
引言 Pirsm框架是由微软P & P小组设计的,用于构建组合式的WPF企业级应用,支持两个IOC容器,分别为Unity和MEF.官方地址为http://compositewpf.codepl ...
- 【Prism】MEF版UIComposition
引言 UIComposition原版Demo在PrismV5的解压包里面.原Demo用了.net4.5版本的DLL,我改成.net4.0的. RegionContext 这个Demo比之前那几个示例大 ...
- 【Prism】MEF版EventAggregation
引言 第三弹是EventAggregation Demo的改造. EventAggregation EventAggregation事件聚集是Prism框架中的通信实现.它可以在松散的模块或者窗体之 ...
- Prism&MEF构建开发框架 (三)
菜单管控模块EntityFW 菜单的加载采用MEF技术,程序实现思路: 1 .主菜单加载页面MainMenuView.xaml指向MenuRegion 2. 菜单Item点击及内容加载,采用订阅模式, ...
- 一步步实现 Prism + MEF(一)--- 搭建框架
第一步:构建一个名为Bootstrapper的类作为引导程序. class Bootstrapper : MefBootstrapper { } 第二步:在MainWindow窗体中添加一个Coont ...
- Prism MEF example
Related Attributes These attributes are under namespace System.ComponentModel.Composition Import The ...
- 一步步实现 Prism + MEF(二)--- 绑定命令
Prism程序集为我们提供了DelegateCommand命令,使用该命令可实现窗口直接绑定.第一步:在ViewModel中定义一个DelegateCommand属性. public Delegate ...
- Prism&MEF构建开发框架
系统框架构想效果图 平台简单由左侧菜单和右侧内容区以及顶部系统和用户信息区构成 菜单根据系统模块动态加载 右侧,根据左侧选中菜单动态加载子模块,子模块集合以tab选项卡方式布局 系统模块划分为Shel ...
随机推荐
- final 变量
一.final对象 使用final关键字修饰一个变量时,是指引用不能变,引用的对象中的内容还是可以改变的.例如,对于如下语句: final StringBuffer a=new StringBuffe ...
- Redis分布式锁的python实现
案例1: #!/usr/bin/env python # coding=utf-8 import time import redis class RedisLock(object): def __in ...
- Use Private Members from Base Class
最近看了一段代码:在导出类中调用继承自基类的某个public函数,该函数中对基类中的private数据成员 进行了赋值并将结果打印.看到程序的运行结果后,顿时感觉自己之前(我之前的理解这里就不说明了) ...
- python——单例模式
单例模式(Singleton Pattern)是一种常用的软件设计模式,该模式的主要目的是确保某一个类只有一个实例存在. 当你希望在整个系统中,某个类只能出现一个实例时,单例对象就能派上用场. 比如, ...
- NetCDF 介绍
NetCDF 1 NetCDF 1.1概述(Overview) NetCDF (network Common Data Form) is a set of software libraries and ...
- 0607pm克隆&引用类&加载类&面向对象串讲&函数重载
克隆class Ren{ public $name; public $sex; function __construct($n,$s) { $this->name=$n; $this->s ...
- HTML中表格的使用
表格: <table></table>表格 width:宽度.可以用像素或百分比表示. 常用960像素. border:边框,常用值为0. cellpadding:内容跟边框的 ...
- dataTables的用法
原地址:http://blog.csdn.net/mickey_miki/article/details/8240477 1.DataTables的默认配置 $(document).ready(fun ...
- Understanding When to use RabbitMQ or Apache Kafka
https://content.pivotal.io/rabbitmq/understanding-when-to-use-rabbitmq-or-apache-kafka How do humans ...
- 关于Class.getResourceAsStream
Properties properties = new Properties(); properties.load(new InputStreamReader(CharactorTest.cl ...