应用UpdateSourceTrigger = PropertyChanged的所有文本框的WPF [英] Apply UpdateSourceTrigger=PropertyChanged to all textboxes wpf

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

问题描述

我怎么能写模板这个样子的。



 < D​​ataTemplate中...... TextBlock的> 
UpdateSourceTrigger = PropertyChanged的
< / DataTemplate中>


解决方案

您不能改变的默认模式为 UpdateSourceTrigger 在样式。这被配置为 DefaultUpdateSourceTrigger FrameworkPropertyMetadata 类的当的DependencyProperty (在这种情况下,文本属性)注册。



您既可以创建自定义的文本框中键入从框派生和变更注册依赖属性时,该值。或者,你可能想看看进入 Caliburn.Micro MVVM框架,它会自动将该对于一个应用程序的所有文本框(通过代码作为基结合其约定)的一部分。


How can I write template look like this?

    <DataTemplate ... TextBlock>
    UpdateSourceTrigger=PropertyChanged
    </DataTemplate>

解决方案

You cannot change the default mode for the UpdateSourceTrigger in a style. This is configured as the DefaultUpdateSourceTrigger of the FrameworkPropertyMetadata class when the DependencyProperty (in this case the Text property) is registered.

You could either create a custom text box type which derives from TextBox and changes this value when registering the dependency property. Alternatively, you might want to look into the Caliburn.Micro MVVM framework, which automatically sets this for all text boxes in an app (via code, as part of its convention based binding).

这篇关于应用UpdateSourceTrigger = PropertyChanged的所有文本框的WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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