【问题标题】:In XAML is there a way to default the UpdateSourceTrigger to PropertyChanged?在 XAML 中有没有办法将 UpdateSourceTrigger 默认为 PropertyChanged?
【发布时间】:2011-04-15 11:40:52
【问题描述】:

【问题讨论】:

  • UpdateSourceTrigger 是大多数属性的默认值。唯一具有不同默认值(据我所知)的是 TextBox 上的 Text 属性。在 Silverlight 中,您无法更改 SourceTrigger 的默认值

标签: .net wpf silverlight data-binding xaml


【解决方案1】:

在 WPF 中,UpdateSourceTrigger 对每个控件都有不同的默认值,并且无法设置任何东西来控制所有元素如何设置它们的 UpdateSourceTrigger!您绝对可以创建一个可以遍历页面并更改所有值的附加行为?

<Window
     local:DefaultUpdateSourceTrigger="PropertyChanged">

</Window>

然后这可以遍历可视化树并更改 UpdateSourceTriggers!

【讨论】:

  • 没有实现的代码 sn-p 没有任何价值。
【解决方案2】:

最后我选择了这个

public class BindingEx:Binding
{
    public BindingEx()
    {
        UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
    }
}

【讨论】:

    猜你喜欢
    • 2019-09-10
    • 2012-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-03
    • 2018-08-06
    • 1970-01-01
    相关资源
    最近更新 更多