namespace TriggerAction
{
public class OpenWindowAction : TriggerAction<DependencyObject>
{ public Type WindowType
{
get { return (Type)GetValue(WindowTypeProperty); }
set { SetValue(WindowTypeProperty, value); }
} public static readonly DependencyProperty WindowTypeProperty =
DependencyProperty.Register("WindowType", typeof(Type), typeof(OpenWindowAction), new PropertyMetadata(null)); protected override void Invoke(object parameter)
{
var windowObj= Activator.CreateInstance(WindowType) as Window;
windowObj.ShowDialog();
}
} public class ButtonAction : TriggerAction<Button>
{
protected override void Invoke(object parameter)
{
this.AssociatedObject.Content = DateTime.Now.ToString();
}
} public class ButtonTargetAction : TargetedTriggerAction<Button>
{
protected override void Invoke(object parameter)
{
this.Target.Content = this.Target.Content + "";
}
}
}
<Window x:Class="TriggerAction.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:local="clr-namespace:TriggerAction" mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Button Content="Button" HorizontalAlignment="Left" Margin="531,122,0,0" VerticalAlignment="Top" Width="164" Height="46">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<local:OpenWindowAction WindowType="{x:Type local:Window1}" />
<local:ButtonAction />
<local:ButtonTargetAction TargetName="aaa" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button x:Name="aaa" Content="Button" HorizontalAlignment="Left" Margin="531,238,0,0" VerticalAlignment="Top" Width="103" Height="30"/> </Grid>
</Window>

WPF TriggerAction弹出子窗体 TargetedTrigger、TargetedTriggerAction用法的更多相关文章

  1. DevExpress第三方控件使用实例之ASPxPopupControl弹出子窗体

    弹出页面控件:ASPxPopupControl, <dxpc:ASPxPopupControl ID="popubCtr" runat="server" ...

  2. WPF 介绍一种在MVVM模式下弹出子窗体的方式

    主要是通过一个WindowManager管理类,在window后台代码中通过WindowManager注册需要弹出的窗体类型,在ViewModel通过WindowManager的Show方法,显示出来 ...

  3. WPF 在MVVM模式下弹出子窗体的方式

    主要是通过一个WindowManager管理类,在window后台代码中通过WindowManager注册需要弹出的窗体类型,在ViewModel通过WindowManager的Show方法,显示出来 ...

  4. WPF 利用子线程弹出子窗体的研究

    一般来说子线程都是用来处理数据的,主窗体用来实现展现,但是有些时候我们希望子窗体实现等待效果,遮挡主窗体并使主窗体逻辑正常进行,这个业务需求虽然不多,但是正好我们用到了,于是我打算把研究成果写在这了. ...

  5. [Prism框架实用分享]如何在主程序中合理的弹出子窗体

    大家好 说起子窗体,大家都会想到ChildWindow,多熟悉的一个控件.不错,Sliverlight中已经提供了子窗体的具体实现,而在WPF中却没有这么好的事情(有的第三方控件商已经提供此控件).最 ...

  6. Prism框架 如何在主程序中合理的弹出子窗体

    说起子窗体,大家都会想到ChildWindow,多熟悉的一个控件.不错,Sliverlight中已经提供了子窗体的具体实现,而在WPF中却没有这么好的事情(有的第三方控件商已经提供此控件).最常见的实 ...

  7. WPF:设置弹出子菜单的是否可用状态及效果

    需求: 设置弹出子菜单(二级)项仅首项可用,其他项均不可用:不可用是呈灰色效果. 注: 菜单项都是依据层级数据模板.具体格式如下: StackBlock{TextBlock{Image}.TextBl ...

  8. WPF FileFolderDialog 和弹出子窗口的一些问题

    摘要:本文主要是WPF中 FileFolderDialog的相关问题,补充了关于在父窗口弹出子窗口,以及子窗口的相关属性(Data Binding)和命令绑定(Delegate Command)问题, ...

  9. WPF的WebBrowser屏蔽弹出脚本错误窗体

    WPF自带的WebBrowser在訪问一些有问题的网页时常常跳出非常多提示脚本错误的窗体, 可是WPF没有自带屏蔽这些窗体的方法或属性. 所以网上找来一使用反射的方法来屏蔽弹出脚本错误窗体的方法, 非 ...

随机推荐

  1. 基于sersync海量文件实时同步

    项目需求:最近涉及到数百万张图片从本地存储迁移到云存储,为了使完成图片迁移,并保证图片无缺失,业务不中断,决定采用实时同步,同步完后再做流量切换.在实时同步方案中进行了几种尝试. 方案1:rsync+ ...

  2. javascript常用验证大全

    1. 长度限制 <script> function test() { if(document.a.b.value.length>50) { alert("不能超过50个字符 ...

  3. 问题记录,StartCoroutine(“str")问题

    StartCoroutine参数为函数字符串名,运行时出错,错误是:无法启动协程函数. 调用格式如下: gameManager.StartCoroutine(LuaOnLevelwasloaded() ...

  4. python模块的打包

    python模块的打包方法: http://blog.csdn.net/five3/article/details/7847551

  5. 什么是First-class citizen?

    [什么是First-class citizen?] In programming language design, a first-class citizen (also type, object,  ...

  6. UnityEngine.SerializeField & System.Serializable

    [UnityEngine.SerializeField] Force Unity to serialize a private field. 强制Unity序列化一个私有变量. You will al ...

  7. go_组合接口

    main函数入口 package main import ( "fmt" "learngo/retriever/mock" "learngo/retr ...

  8. SpringBoot简单理解

    SpringBoot 一.特点:1.默认大于配置,不需要大量配置文件,没有web.xml,拥有可运行的Application类. 2.一般通过java代码配置,而尽量少使用xml配置. 3.maven ...

  9. react-native 组件的导入、导出

    一.前言背景: 学习react native的关键在于组件,依靠组件的拼接达到想要的效果,由此可见,组件就像一块块功能各异的零件,最终搭建出我们想要的效果. 今天我们就从组件的导入.导出开始 下面是我 ...

  10. Spring Boot gradle 集成servlet/jsp 教程及示例

    1.build.gradle 配置 注意,加入了war插件,在依赖中加入了jstl.tomcat-embed-jasper,这样才能运行jsp页面. buildscript { ext { sprin ...