Prism.Interactivity: 主要用来截取View即界面的一些处理,而这些功能通过vm 不好实现,只能用 CommandBehaviorBase 来截取处理,特别是在处理界面异常很有用。

定义如下:

public class ValidationExceptionBehavior : Behavior<FrameworkElement>

{

// 方法体

}

使用:

界面错误信息的处理:

<Interactivity:Interaction.Behaviors>                <common:ValidationExceptionBehavior></common:ValidationExceptionBehavior>

</Interactivity:Interaction.Behaviors>

键盘事件的处理

<Interactivity:Interaction.Triggers>

<Interactivity:EventTrigger EventName="KeyDown">

<Interactivity:InvokeCommandAction Command="{Binding ButtonKeyDown}"

CommandParameter="{Binding RelativeSource={RelativeSource  Mode=FindAncestor, AncestorType={x:Type Window}}}"/>

</Interactivity:EventTrigger>

</Interactivity:Interaction.Triggers>

注意界面要引用:

xmlns:Interactivity=http://schemas.microsoft.com/expression/2010/interactivity

Prism.Modularity: 模块定义,加载,管理

继承 IModule

public class PositionModule : IModule

{

// 其他内容

///必须实现 Initialize ,注册该模块中使用的服务,vm 等。提供主程序中使用。

public void Initialize()

{

.....

this.container.RegisterType<IOrdersViewModel, OrdersViewModel>();

this.container.RegisterType<IOrdersView, OrdersView>();

this.container.RegisterType<IOrderCompositeViewModel, OrderCompositeViewModel>();

this.container.RegisterType<IPositionSummaryViewModel, PositionSummaryViewModel>();

this.container.RegisterType<IPositionPieChartViewModel, PositionPieChartViewModel>();

this.regionManager.RegisterViewWithRegion(RegionNames.MainRegion,

() => this.container.Resolve<PositionSummaryView>());

this._ordersController = this.container.Resolve<OrdersController>();

}

}

主程序中使用方法:

在 Bootstrapper 中使用:

public class StockTraderRIBootstrapper : UnityBootstrapper

{

protected override void ConfigureModuleCatalog()

{

base.ConfigureModuleCatalog();

ModuleCatalog moduleCatalog = (ModuleCatalog)this.ModuleCatalog;                   moduleCatalog.AddModule(typeof(StockTraderRI.Modules.Position.PositionModule));                     moduleCatalog.AddModule(typeof(StockTraderRI.Modules.News.NewsModule));

}

protected override DependencyObject CreateShell()

{

// Use the container to create an instance of the shell.

Shell view = this.Container.TryResolve<Shell>();

view.DataContext = new ShellViewModel();

return view;

}

protected override void InitializeShell()

{

base.InitializeShell();

App.Current.MainWindow = (Window)this.Shell;

App.Current.MainWindow.Show();

}

protected override Prism.Regions.IRegionBehaviorFactory ConfigureDefaultRegionBehaviors()

{

var factory = base.ConfigureDefaultRegionBehaviors();

return factory;

}

}

这是通过代码实现的,也可以通过 xml 配置文件实现

protected override IModuleCatalog CreateModuleCatalog() {     return ModuleCatalog.CreateFromXaml(new Uri("/MyProject;component/ModulesCatalog.xaml", UriKind.Relative)); }

Prism.Interactivity 和 Prism.Modularity 介绍的更多相关文章

  1. Prism.Interactivity 之 PopupWindowAction 用法简记

    PopupWindow通过InteractionRequestTrigger(EventTrigger的派生类)侦听目标对象(InteractionRequest<T>类型)的Raised ...

  2. [Windows] Prism 8.0 入门(下):Prism.Wpf 和 Prism.Unity

    1. Prism.Wpf 和 Prism.Unity 这篇是 Prism 8.0 入门的第二篇文章,上一篇介绍了 Prism.Core,这篇文章主要介绍 Prism.Wpf 和 Prism.Unity ...

  3. 下载并安装Prism5.0库 Download and Setup Prism Library 5.0 for WPF(英汉对照版)

    Learn what’s included in Prism 5.0 including the documentation, WPF code samples, and libraries. Add ...

  4. WPF Prism MVVM 中 弹出新窗体. 放入用户控件

    原文:WPF Prism MVVM 中 弹出新窗体. 放入用户控件 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/qq_37214567/artic ...

  5. 下载并安装Prism5.0库(纯汉语版)

    Prism5.0中包含了文档,WPF代码示例,程序集.本篇告诉你从哪里获取程序集和代码示例,还有NuGet包的内容. 对于新功能,资产,和API的更改信息,请看Prism5.0新内容. 文档 Pris ...

  6. 1: 介绍Prism5.0 Introduction to the Prism Library 5.0 for WPF(英汉对照版)

     Prism provides guidance designed to help you more easily design and build rich, flexible, and easy- ...

  7. Prism5.0开发人员指南内容 Contents of the Developer's Guide to Prism Library 5.0 for WPF(英汉对照版)

    The Prism for WPF guide contains the following topics: Prism指南包含以下内容: Download and Setup Prism 下载并安装 ...

  8. Prism5.0新内容 What's New in Prism Library 5.0 for WPF(英汉对照版)

    Prism 5.0 includes guidance in several new areas, resulting in new code in the Prism Library for WPF ...

  9. Prism开发人员指南5-WPF开发 Developer's Guide to Microsoft Prism Library 5.0 for WPF (英汉对照版)

    April 2014 2014四月   Prism provides guidance in the form of samples and documentation that help you e ...

随机推荐

  1. SpringMVC+Spring+Hibernate个人家庭财务管理系统

    项目描述 Hi,大家好,今天分享的项目是<个人家庭财务管理系统>,本系统是针对个人家庭内部的财务管理而开发的,大体功能模块如下: 系统管理模块 验证用户登录功能:该功能主要是验证用户登录时 ...

  2. Python3笔记022 - 5.1 字符串常用操作

    第5章 字符串及正则表达式 5.1 字符串常用操作 5.1.1 拼接字符串 使用+运算符可完成多个字符串的拼接,产生一个新的字符串对象. str1 = "2020年07月06日是" ...

  3. Vue---day05

    目录 2. 客户端项目搭建 2.1 创建项目目录 2.2 初始化项目 2.3 安装路由vue-router 2.3.1 下载安装路由组件 2.3.2 配置路由 2.3.2.1 初始化路由对象 2.3. ...

  4. CTFHub_技能树_SQL注入Ⅱ

    SQL注入 MySQL结构 进行尝试: 尝试查看表名: 尝试查看列名: 发现无法直接输出: 使用时间注入脚本跑出结果: import requests import time session = re ...

  5. Spring @Value注解使用${}进行注入(转)

    原文:http://my.oschina.net/js99st/blog/632104 spring3中新增的@value注解 http://bijian1013.iteye.com/blog/202 ...

  6. day4:运算符

    1.算术运算符:+ - * / // % ** 注意点:1./ 除法,结果为小数  2.// 地板除,返回整数  3.如果被除数或者除数是一个小数,结果加上.0 2.比较运算符:< > & ...

  7. 用maven打包java项目的pom文件配置

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  8. P1050 精卫填海

    [问题描述] 发鸠之山,其上多柘木.有鸟焉,其状如乌,文首,白喙,赤足,名曰精卫,其名自詨.是炎帝之少女,名曰女娃.女娃游于东海,溺而不返,故为精卫.常衔西山之木石,以堙于东海.——<山海经&g ...

  9. IOS上传图片方向问题

    在显示上传完毕的图片的时候遇到了一个问题, 图片莫名其妙被逆时针旋转了90度就很离谱 如下图 经过一番查询, 原来是 IOS 的相机拍照的时候会把方向角写入到图片里面 因为我用的是 element 的 ...

  10. Java 线程与同步的性能优化

    本文探讨的主题是,如何挖掘出Java线程和同步设施的最大性能. 1.线程池与ThreadPoolExecutor 1)线程池与ThreadPoolExecutor 线程池的实现可能有所不同,但基本概念 ...