当前位置:网站首页>【WPF】UpdateSourceTrigger
【WPF】UpdateSourceTrigger
2022-04-22 05:18:00 【Pistachio 2021】
UpdateSourceTrigger: Gets or sets a value , Determine when to update the binding source . The default value is Default
Default : Bind the default value of the target property System.Windows.Data.UpdateSourceTrigger value . The default value for most dependent properties is UpdateSourceTrigger.PropertyChanged, and TextBox.Text The default value of the property is UpdateSourceTrigger.LostFocus.
PropertyChanged: Whenever the binding target property changes , Will update the binding source .
LostFocus : Whenever the binding target element loses focus , Will update the binding source .
Explicit: Only when calling BindingExpression.UpdateSource Method to update the binding source .
<WrapPanel Grid.Row="1" Margin="10">
<TextBlock Text="window title"/>
<TextBox x:Name="txtTitle" Text="{Binding Title,UpdateSourceTrigger=Default}" Width="100" Margin="5 0 5 0"/>
<Button x:Name="_btnUpdateSource" Content="update source" Click="_btnUpdateSource_Click"/>
</WrapPanel>
<WrapPanel Grid.Row="2" Margin="10">
<TextBlock Text="window dimensions:"/>
<TextBox x:Name="txtWidth" Text="{Binding Width,UpdateSourceTrigger=LostFocus}" Width="50"/>
<TextBlock Text="x"/>
<TextBox x:Name="txtHeigth" Text="{Binding Height,UpdateSourceTrigger=PropertyChanged}" Width="50"/>
</WrapPanel>
private void _btnUpdateSource_Click(object sender, RoutedEventArgs e)
{
BindingExpression binding = _txtwindow.GetBindingExpression(TextBox.TextProperty);// Get the binding of the target control
binding.UpdateSource();
}

modify txtTitle Then click update source Button , forms Title change

modify txtWidth Change the mouse focus after , Form width update
modify txtHeight, Form height update

版权声明
本文为[Pistachio 2021]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210625511324.html
边栏推荐
- 【Redis笔记】数据结构和对象:字典
- Vs2019 official free print control
- 2022-4-20 operation
- ThreadLocal underlying analysis
- Meetup 02 review: Q & A highlights
- Command mode (3.21-3.27)
- Log4 log framework
- Mysql database for the 11th time
- Chapter 7 select clause and sub query
- Measuring the impact of a successful DDoS attack on the customer behavior of managed DNS servi
猜你喜欢

Summary of browser cross domain problems

Junit Introduction et Introduction

Reading: analyzing third party service dependencies in modern web services
![[C] file operation](/img/fd/ddf94b0ffa743f2288f723a263a045.png)
[C] file operation

MySQL数据库第十一次

Chapter 7 select clause and sub query

MySQL view character set and proofing rules

Detailed explanation of Neptune w800 lighting (interruption) project

Interpretation of the report Download | the future of database and the development trend and challenges of database in the 14th five year plan

How to restrict Oracle sub query
随机推荐
2022-4-20 operation
JSON class of Delphi: superobject, and simple usage jsonhelper
Nexus私服——(三) 在项目实战中使用私服仓库
Nodejs link redis
Error: ER_ NOT_ SUPPORTED_ AUTH_ MODE: Client does not support authentication protocol requested by serv
Restful style API design
Western dichotomy and Eastern trisection
13.9.1-PointersOnC-20220421
What are the challenges of Internet of things testing, and how do software testing institutions ensure quality
Layer 3 switch [vlanif details] enable OSPF and router interworking [ENSP implementation]
什么是幂等性
Clonal map of writing in mind
Basic security settings of the server
Esp32 vhci realizes ble broadcasting, which is so magical
萌新看过来 | WeDataSphere 开源社区志愿者招募
Query result processing
Unity中的UGUI源码解析之事件系统(9)-输入模块(下)
How to dynamically load parameters, pictures and background pictures for RDLC printing reports of ReportViewer
Log4 日志框架
Junit断言