【WPF/WAF】使用System.Windows.Interactivity交互事件
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了【WPF/WAF】使用System.Windows.Interactivity交互事件,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1287字,纯文字阅读大概需要2分钟。
内容图文
![【WPF/WAF】使用System.Windows.Interactivity交互事件](/upload/InfoBanner/zyjiaocheng/980/0c0edd0d12834a54beba2385f3ce762f.jpg)
下载System.Windows.Interactivity.dll文件,并引入项目中(在VS项目的引用列表中可以看到)。可在Nuget搜索System.Windows.Interactivity下载安装到项目中。
XAML中使用该dll
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
<!-- TextBox控件的获得焦点、失去焦点事件 --> <TextBox Text="Test"> <i:Interaction.Triggers> <i:EventTrigger EventName="LostFocus"> <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=DataContext.OnTextLostFocus}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType={x:Type TextBox}}}"/> </i:EventTrigger> <i:EventTrigger EventName="GotFocus"> <i:InvokeCommandAction Command="{Binding RelativeSource={RelativeSource AncestorType=Window},Path=DataContext.OnTextGotFocus}" CommandParameter="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType={x:Type TextBox}}}"/> </i:EventTrigger> </i:Interaction.Triggers> </TextBox>
由于VS中不支持System.Windows.Interactivity的智能提示,经常要查阅这个EventTrigger还能触发哪些方法,所有EventName的列表如下:
- MSDN中Grid Events https://msdn.microsoft.com/en-us/library/system.windows.controls.grid_events(v=vs.110).aspx
内容总结
以上是互联网集市为您收集整理的【WPF/WAF】使用System.Windows.Interactivity交互事件全部内容,希望文章能够帮你解决【WPF/WAF】使用System.Windows.Interactivity交互事件所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。