当前位置:网站首页>【wpf】Bingding的方向和触发的时机
【wpf】Bingding的方向和触发的时机
2022-08-08 17:52:00 【code bean】
<!--两个方向都可行-->
<TextBox Text="{Binding DM1.Value,UpdateSourceTrigger=PropertyChanged,
Mode=TwoWay}" Name="textBox"/>
<!--只允许从源到目标-->
<TextBox Text="{Binding DM1.Value,Mode=OneWay}" Name="tb2"/>
<!--史允许从目标到源-->
<TextBox Text="{Binding DM1.Value,UpdateSourceTrigger=PropertyChanged,
Mode=OneWayToSource}" />
<!--只允许初始化一次-->
<TextBox Text="{Binding DM1.Value,
Mode=OneTime}"/>
Mode
首先源是指后台数据,目标指,前台显示。
TwoWay:"双向奔赴"。
OneWay 后台数据 -> 前台显示,
OneWayToSource 与OneWay 相反。
OneTime 就只有初始化的时候起作用了。
UpdateSourceTrigger
UpdateSourceTrigger ,表示当前台数据(目标)发送变化时,更新源(后台数据)的时机。(注意:UpdateSourceTrigger 关心的方向是:前台显示->后台数据,所以当Mode为OneWay时,设置这个属性是没有意义的)
//
// 摘要:
// Describes the timing of binding source updates.
public enum UpdateSourceTrigger
{
//
// 摘要:
// The default System.Windows.Data.UpdateSourceTrigger value of the binding target
// property. The default value for most dependency properties is System.Windows.Data.UpdateSourceTrigger.PropertyChanged,
// while the System.Windows.Controls.TextBox.Text property has a default value of
// System.Windows.Data.UpdateSourceTrigger.LostFocus.
Default = 0,
//
// 摘要:
// Updates the binding source immediately whenever the binding target property changes.
PropertyChanged = 1,
//
// 摘要:
// Updates the binding source whenever the binding target element loses focus.
LostFocus = 2,
//
// 摘要:
// Updates the binding source only when you call the System.Windows.Data.BindingExpression.UpdateSource
// method.
Explicit = 3
}
PropertyChanged
表示,只要前台发送变化,立马通知源(也就是调用属性的set方法)
LostFocus
表示控件失去焦点时触发。
Explicit
通过绑定表达式调用UpdateSource调用后触发。
//获取绑定表达式
BindingExpression bindingExpression = textBox.GetBindingExpression(TextBox.TextProperty);
//调用后触发
bindingExpression.UpdateSource();
边栏推荐
- spark学习笔记(八)——sparkSQL概述-定义/特点/DataFrame/DataSet
- Superficial understanding of ports
- orbslam2实验记录-----稠密建图
- mysql中模糊查询的四种用法介绍
- Node基于TCP建立的服务器
- DSPE-PEG-NH2,DSPE-PEG-amine,474922-26-4,磷脂-聚乙二醇-氨基科研试剂
- List<String>用空串替换null值,并且都加上单引号,并且转为字符串用,分割
- 【TypeScript】函数类型:返回值类型和参数类型到底如何定义?
- The difference between rv and sv
- js切换新闻列表样式
猜你喜欢

Go源码之原子操作(atomic)

Neo4j:一、CQL语句

从2022投影行业最新报告,读懂2022年家用智能投影仪该怎么选!

【CC3200AI 实验教程4】疯壳·AI语音人脸识别(会议记录仪/人脸打卡机)-GPIO

CF1165F2(二分答案)

21天学习第二天-类型转换

Detailed explanation of JVM memory model and structure (five model diagrams)

Fluorescein-PEG-CLS,胆固醇-聚乙二醇-荧光素用于缩短包封周期

医疗机构漏诊,该不该赔?--一起交通事故多处骨折,又遇到医疗机构漏诊

阿里巴巴云原生大数据运维平台 SREWorks 正式开源
随机推荐
高维前缀和和子集dp(状压dp的一种)
无需精子卵子子宫体外培育胚胎,Cell论文作者这番话让网友们炸了
转载,fragment讲的很好的大佬
yarn : 无法加载文件 D:xxx\node_global\yarn.ps1 因为在此系统上禁止运行脚本
CF803F(容斥原理+莫比乌斯函数)
建设必要的是什么意思
多线程之不可变对象
Why do you need to cross compiler
【CC3200AI 实验教程4】疯壳·AI语音人脸识别(会议记录仪/人脸打卡机)-GPIO
【目标检测】YOLOv5:标签中文显示/自定义颜色
彻底理解 volatile 关键字及应用场景,面试必问,小白都能看懂!
1dp到底多大!
在指南针炒股软件中的指标靠谱吗?安全吗?
Node基于TCP建立的服务器
@Transactional
在启牛学堂股票开户安全吗?
win10如何设置定时联网断网辅助自律
请教一个oracle - cdc问题。 设置为 StartupOptions.latest()
CS231n:12 强化学习
记录贴:pytorch学习Part3