WPF TriggerAction弹出子窗体 TargetedTrigger、TargetedTriggerAction用法
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用法的更多相关文章
- DevExpress第三方控件使用实例之ASPxPopupControl弹出子窗体
弹出页面控件:ASPxPopupControl, <dxpc:ASPxPopupControl ID="popubCtr" runat="server" ...
- WPF 介绍一种在MVVM模式下弹出子窗体的方式
主要是通过一个WindowManager管理类,在window后台代码中通过WindowManager注册需要弹出的窗体类型,在ViewModel通过WindowManager的Show方法,显示出来 ...
- WPF 在MVVM模式下弹出子窗体的方式
主要是通过一个WindowManager管理类,在window后台代码中通过WindowManager注册需要弹出的窗体类型,在ViewModel通过WindowManager的Show方法,显示出来 ...
- WPF 利用子线程弹出子窗体的研究
一般来说子线程都是用来处理数据的,主窗体用来实现展现,但是有些时候我们希望子窗体实现等待效果,遮挡主窗体并使主窗体逻辑正常进行,这个业务需求虽然不多,但是正好我们用到了,于是我打算把研究成果写在这了. ...
- [Prism框架实用分享]如何在主程序中合理的弹出子窗体
大家好 说起子窗体,大家都会想到ChildWindow,多熟悉的一个控件.不错,Sliverlight中已经提供了子窗体的具体实现,而在WPF中却没有这么好的事情(有的第三方控件商已经提供此控件).最 ...
- Prism框架 如何在主程序中合理的弹出子窗体
说起子窗体,大家都会想到ChildWindow,多熟悉的一个控件.不错,Sliverlight中已经提供了子窗体的具体实现,而在WPF中却没有这么好的事情(有的第三方控件商已经提供此控件).最常见的实 ...
- WPF:设置弹出子菜单的是否可用状态及效果
需求: 设置弹出子菜单(二级)项仅首项可用,其他项均不可用:不可用是呈灰色效果. 注: 菜单项都是依据层级数据模板.具体格式如下: StackBlock{TextBlock{Image}.TextBl ...
- WPF FileFolderDialog 和弹出子窗口的一些问题
摘要:本文主要是WPF中 FileFolderDialog的相关问题,补充了关于在父窗口弹出子窗口,以及子窗口的相关属性(Data Binding)和命令绑定(Delegate Command)问题, ...
- WPF的WebBrowser屏蔽弹出脚本错误窗体
WPF自带的WebBrowser在訪问一些有问题的网页时常常跳出非常多提示脚本错误的窗体, 可是WPF没有自带屏蔽这些窗体的方法或属性. 所以网上找来一使用反射的方法来屏蔽弹出脚本错误窗体的方法, 非 ...
随机推荐
- Selenium2+python自动化63-简易项目搭建
前言 到unittest这里基本上可以搭建一个简易的项目框架了,我们可以用一条run_main.py脚本去控制执行所有的用例,并生成报告,发送邮件一系列的动作 一.新建工程 1.打开pycharm左上 ...
- 网络通信和TCP详解
交换机.路由器.服务器组网 1. 通信过程(pc+switch+router+server) 较为复杂的通信过程如:访问 www.baidu.com 注意:一定要配置 PC:IP.NETMASK.DF ...
- 内存表 FDMemTable ClientDataSet CreateDataSet 动态创建字段
https://community.embarcadero.com/index.php/blogs/entry/firedac-in-memory-dataset-tfdmemtable Client ...
- YARN 多租户资源池配置
简介: YARN 多租户资源池配置 当多用户同在一个 hadoop 集群作业时,就需要对资源进行有效的限制,例如区分测试.正式资源等 一.查看默认资源池 # 访问:http://192.168.1.2 ...
- IOS CGAffineTransform 用于视图平移,放缩,旋转
转载于:http://blog.csdn.net/lc_obj/article/details/17454825 CGAffineTransform 今天碰到了一个旋转放缩图片的一个demo,在看的过 ...
- python's output redirect
[python's output redirect] fin = open("xx.txt", 'r'); print >>fin, "hello world ...
- 5-青蛙的约会(ex_gcd)
青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submissions:122411 Accepted: 25980 Descripti ...
- linux下mysql开启远程访问权限及防火墙开放3306端口(mysql开放host访问权限)
开启mysql的远程访问权限默认mysql的用户是没有远程访问的权限的,因此当程序跟数据库不在同一台服务器上时,我们需要开启mysql的远程访问权限.主流的有两种方法,改表法和授权法.相对而言,改表法 ...
- 安装bcmath 扩展
1.在php源码包中,默认就包含bcmath扩展的安装文件,只需手动安装一下即可 cd /root/build2/php-/ext/bcmath // 进入PHP的源码包目录中的bcmatch扩展目录 ...
- 一些使用的linux库
1.curl网络库 apt-get install libcurl4-openssl-dev sudo apt-get install curl 2.jsoncpp库 sudo apt-get ins ...