描述UpdateSourceTrigger的所有属性 [英] Describe all properties of UpdateSourceTrigger

查看:48
本文介绍了描述UpdateSourceTrigger的所有属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有人,

我确实尝试了有关UpdatesourceTrigger 的所有  4个属性.默认,丢失焦点,属性更改和显式.

I did try  all  4 properties about UpdatesourceTrigger  . Default,LostFocus,PropertyChange and Explicit .

尝试此链接:

http://www.c-sharpcorner.com/uploadfile/41e70f/overview-of-updatesourcetrigger-and-its-properties/

http://www.c-sharpcorner.com/uploadfile/41e70f/overview-of-updatesourcetrigger-and-its-properties/

当我在UpdateSourceTrigger中使用所有  4属性时,源到目标的更改都没有.

when i used all  4 properties in UpdateSourceTrigger , than not any changes in Source to destination .

请给出有关 Default,LostFocus,PropertyChange和Explicity的任何好例子.

Please give  any good example about Default , LostFocus , PropertyChange and Explicity .

当更改UpdateSourceTrigger中的所有4个属性时,会发生什么变化.

致谢

A.Acharya对我们的反馈在Windows Store中开发和推广您的应用程序,如果有帮助,请记住将其标记为答案,如果没有帮助,则将其取消标记.

A.Acharya Feedback to us Develop and promote your apps in Windows Store Please remember to mark the replies as answers if they help and unmark them if they provide no help.

推荐答案

它们都在MSDN上的文档中进行了描述:

They are all described in the documentation on MSDN: https://msdn.microsoft.com/en-us/library/system.windows.data.updatesourcetrigger(v=vs.110).aspx

有关更多信息,请参阅我的有关WPF中数据验证的博客文章: https://blog.magnusmontin.net/2013/08/26/data-validation -in-wpf/

You can refer to my blog post about data validation in WPF for more information: https://blog.magnusmontin.net/2013/08/26/data-validation-in-wpf/

" ......对于TwoWay和OneWayToSource绑定,在Binding类上有一个名为UpdateSourceTrigger的附加属性,用于指定触发源属性更新的内容.如果UpdateSourceTrigger设置为LostFocus,这是默认设置 对于TextBox控件的Text属性,您在TextBox中键入的文本不会更新source属性,直到控件失去焦点(单击该控件时会发生焦点).如果您需要更新来源,即 要调用DataContext的bound属性,当用户在TextBox中键入内容时,请将UpdateSourceTrigger属性设置为PropertyChanged:

"...For TwoWay and OneWayToSource bindings there is an additional property on the Binding class named UpdateSourceTrigger that specifies what triggers the update of a source property. If the UpdateSourceTrigger is set to LostFocus, which is the default for the Text property of the TextBox control, the text you type into the TextBox does not update the source property until the control loses focus which happens when you click away from it. If you require the source to get updated, i.e. the setter for the bound property of the DataContext to get called, as the user is typing into the TextBox you set the UpdateSourceTrigger property to PropertyChanged:

<TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" />


 

除了默认选项的工作方式与BindingMode枚举中的选项相似外,System.Windows.Data.Binding.UpdateSourceTrigger枚举中还定义了一个名为Explicit的选项.将该属性设置为该值表示该值 仅当您在代码中显式调用BindingExpression.UpdateSource()方法时,source属性的属性才会更新.不过,通常您永远不会在MVVM应用程序中使用这种方法."


 

Besides a Default option that works similar to the one in the BindingMode enumeration, there is also an option called Explicit defined in the System.Windows.Data.Binding.UpdateSourceTrigger enumeration. Setting the property to this value means that the value of the source property only gets updated when you explicitly call the BindingExpression.UpdateSource() method in code. You will typically never use this approach in an MVVM application though."

希望有帮助.

请记住,通过将有用的帖子标记为答案来关闭话题,然后在遇到新问题时开始新话题.请不要在同一线程中问几个问题.

Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.


这篇关于描述UpdateSourceTrigger的所有属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆