【问题标题】:Mvvm wpf: update value binding before leaving focus of input elementMvvm wpf:在离开输入元素的焦点之前更新值绑定
【发布时间】:2014-10-09 08:55:51
【问题描述】:

我的 xaml(DevExpress 项目)中有这个元素:

<dxe:ComboBoxEdit IsTextEditable="False" EditValue="{Binding IDTIPOCONN}" 
     ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=Window},Path=DataContext.ttc}"  />

所有绑定都是正确的,当我更改值时,我会从我的 ViewModel 触发一些事件。

我的问题是只有当我离开组合框的焦点时才会执行值的更新。相反,我需要在值更改时执行我的操作,然后再离开它的焦点。

我该怎么做?我需要这个,因为从列表中选择一个或另一个,我会向用户显示一些隐藏的元素。

【问题讨论】:

    标签: c# wpf xaml mvvm binding


    【解决方案1】:

    尝试绑定集UpdateSourceTrigger=PropertyChanged

    <dxe:ComboBoxEdit IsTextEditable="False"
                      EditValue="{Binding Path=IDTIPOCONN, UpdateSourceTrigger=PropertyChanged}" ... />
    

    在这种情况下,UpdateSourceTrigger 的默认值很可能是LostFocus

    【讨论】:

    • 也许 UpdateSourceTrigger=LostFocus? :)
    • @ValeraScherbakov:引用问题:My problem is the update of the value is executed only when I leave the focus of my comboBox.
    • @AnatoliyNikolaev 这正是我需要的!它完美、简单、有效!!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-15
    • 1970-01-01
    • 2015-06-12
    • 2022-01-10
    • 1970-01-01
    • 1970-01-01
    • 2019-03-13
    相关资源
    最近更新 更多