【WPF系列】-TextBox常用知识点
DataBinding中更新数据源的时机
TextBox .Text 属性的默认 UpdateSourceTrigger 值为 LostFocus。这意味着如果应用程序的 TextBox 包含数据绑定 TextBox.Text 属性,则直到 TextBox 失去焦点(例如,将鼠标移到TextBox 外单击时),键入到 TextBox 中的文本才能更新源。
如果希望在键入过程中更新源,请将该绑定的 UpdateSourceTrigger 设置为 PropertyChanged。 在下面的示例中,TextBox 和 TextBlock 的 Text 属性都绑定到同一源属性。 将 TextBox绑定的 UpdateSourceTrigger 属性设置为 PropertyChanged。

<Label>Enter a Name:</Label>
<TextBox>
<TextBox.Text>
<Binding Source="{StaticResource myDataSource}" Path="Name"
UpdateSourceTrigger="PropertyChanged"/>
</TextBox.Text>
</TextBox> <Label>The name you entered:</Label>
<TextBlock Text="{Binding Source={StaticResource myDataSource}, Path=Name}"/>
高级实例:
通过dataTriger来给TextBox焦点
Using XAML to Set Focus on a Textbox in WPF Desktop Applications

<Style x:Key="LayoutRoot" TargetType="Grid">
<Style.Triggers>
<!--these are the triggers that make the code cursor jump from box 1 to box 2 to box 3.-->
<DataTrigger Binding="{Binding ElementName=CodeDigit1, Path=Text.Length}" Value="1">
<Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=CodeDigit2}"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=CodeDigit2, Path=Text.Length}" Value="1">
<Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=CodeDigit3}"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=CodeDigit3, Path=Text.Length}" Value="1">
<Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=CodeDigit4}"/>
</DataTrigger>
<DataTrigger Binding="{Binding ElementName=CodeDigit4, Path=Text.Length}" Value="1">
<Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=ConnectButton}"/>
</DataTrigger>
</Style.Triggers>
</Style>
【WPF系列】-TextBox常用知识点的更多相关文章
- WPF中的常用布局 栈的实现 一个关于素数的神奇性质 C# defualt关键字默认值用法 接口通俗理解 C# Json序列化和反序列化 ASP.NET CORE系列【五】webapi整理以及RESTful风格化
WPF中的常用布局 一 写在开头1.1 写在开头微软是一家伟大的公司.评价一门技术的好坏得看具体的需求,没有哪门技术是面面俱到地好,应该抛弃对微软和微软的技术的偏见. 1.2 本文内容本文主要内容 ...
- [WPF系列]-TreeView的常用事项
引言 项目经常会用Treeview来组织一些具有层级结构的数据,本节就将项目使用Treeview常见的问题作一个总结. DataBinding数据绑定 DataTemplate自定义 <Hier ...
- [WPF系列]-数据邦定之DataTemplate 对分层数据的支持
到目前为止,我们仅讨论如何绑定和显示单个集合. 某些时候,您要绑定的集合包含其他集合. HierarchicalDataTemplate 类专用于 HeaderedItemsControl 类型以显示 ...
- [WPF系列]-数据邦定之DataTemplate 根据对象属性切换模板
引言 书接上回[WPF系列-数据邦定之DataTemplate],本篇介绍如何根据属性切换模板(DataTemplate) 切换模板的两种方式: 使用DataTemplateSelecto ...
- [WPF系列]-DataBinding(数据绑定) 自定义Binding
自定义Binding A base class for custom WPF binding markup extensions BindingDecoratorBase Code: public c ...
- 【WPF系列】基础学习-WPF设计模式概览
引言 “设计模式”这个让程序员提起来就“酷”的东东,着实让让初学设计模式的programer自我陶醉一番.太多的经历,告诉我们“凡事都要个度,要学会适可而止”,否则过犹不及.“设计模式”也一样,切莫为 ...
- [WPF系列]从基础起步学习系列计划
引言 WPF技术已经算不什么新技术,一搜一大把关于WPF基础甚至高级的内容.之前工作中一直使用winform所以一直没有深入学习WPF,这次因项目中使用了WPF技术来实现比较酷的展示界面.我在这里只是 ...
- Java基础复习笔记系列 五 常用类
Java基础复习笔记系列之 常用类 1.String类介绍. 首先看类所属的包:java.lang.String类. 再看它的构造方法: 2. String s1 = “hello”: String ...
- DB2_SQL_常用知识点&实践
DB2_SQL_常用知识点&实践 一.删除表中的数据(delete或truncate) 1 truncate table T_USER immediate; 说明:Truncate是一个能够快 ...
随机推荐
- Buff系统设计
我就随便一写,你也就随便一看吧. 什么是BUFF? 或许直接回答这个问题,那么你收获到的答案将是五花八门的.这个问题暂时放下不谈,我们可以去看其他的游戏应该是怎么设计的. 我经常玩的游戏里边B ...
- eclipse报错:Failed to load the JNI shared library
Eclipse运行时提示“Failed to load the JNI shared library /Java/jre6/bin/client/jvm.dll”的一个解决方案 因为 Eclipse ...
- Java时间和时间戳的相互转换
时间转换为时间戳: /* * 将时间转换为时间戳 */ public static String dateToStamp(String s) throws ParseException{ String ...
- SpringMVC处理客户端请求的过程
SpringMVC处理客户端请求的过程 以程序部署在Tomcat上为例,网站程序使用SpringMVC框架开发. 1.客户端发起一个访问网站的请求(如: localhost:8080/index). ...
- spring aop注解配置
spring aop是面向切面编程,使用了动态代理的技术,这样可以使业务逻辑的代码不掺入其他乱七八糟的代码 可以在切面上实现合法性校验.权限检验.日志记录... spring aop 用的多的有两种配 ...
- cocos2d-x3.3 以前版本 工程Xcode6编译时的问题
Undefined symbols for architecture i386: "_fwrite$UNIX2003", referenced from: _unixErrorHa ...
- .NET 数据类型转换 方法
using Newtonsoft.Json;using Newtonsoft.Json.Converters;using System.Web.Script.Serialization; /// &l ...
- Android—Socket中关闭IO流后导致Socket关闭不能再收发数据的解决办法
以Socket发送数据为例: 发送数据时候要声明:DataOutputStream os = new DataOutputStream(socket.getOutputStream()); 最近开发遇 ...
- android对话框的EditText点击后不显示输入法的问题
dialog.show(); // 以下两行代码是对话框的EditText点击后不能显示输入法的 dialog.getWindow().clearFlags( WindowManager.Layout ...
- Android原生json和fastjson的简单使用
android原生操作json数据 主要是两个类 JSONObject 操作对象 JONSArray操作json数组 对象转json //创建学生对象 Student student=new ...