惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
S
Securelist
D
Docker
The Register - Security
The Register - Security
GbyAI
GbyAI
Recorded Future
Recorded Future
Engineering at Meta
Engineering at Meta
Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
罗磊的独立博客
博客园 - 【当耐特】
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
SecWiki News
SecWiki News
L
Lohrmann on Cybersecurity
I
InfoQ
MyScale Blog
MyScale Blog
量子位
Cyberwarzone
Cyberwarzone
博客园 - 三生石上(FineUI控件)
The Hacker News
The Hacker News
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
博客园_首页
H
Help Net Security
K
Kaspersky official blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
Blog — PlanetScale
Blog — PlanetScale
V
Vulnerabilities – Threatpost
Y
Y Combinator Blog
The Cloudflare Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tailwind CSS Blog
爱范儿
爱范儿
P
Privacy International News Feed
Security Archives - TechRepublic
Security Archives - TechRepublic
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
B
Blog RSS Feed

博客园 - 天涯

Prism BindableBase 和 Commands 的介绍 对 mvvm 架构的理解 wpf mvvm 架构 C#硬件开发业务流程调试技巧 wpf winform 截图 wpf Cannot locate resource 'app.xaml' app.config ConfigSection 保护 程序开发注意4项,你知道吗? .net 变量缓存,你知道吗 wpf 多线程 更新UI 界面 wpf treeview 绑定不同的对象 .net 技术,你掌握了多少 aspx 中确认删除 脚本 - 天涯 .net 中对类的扩展 奇怪--ORA-12154:TNS:无法处理服务名: 建模十条原则 由软件加壳谈起 Hashtable 应注意的 2 点 vb 调用c#做的com 组件
Prism.Interactivity 和 Prism.Modularity 介绍
天涯 · 2020-07-30 · via 博客园 - 天涯

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)); }