文本框绑定到两个LostFoucus和属性更新 [英] Textbox Binding to both LostFoucus and Property Update

查看:169
本文介绍了文本框绑定到两个LostFoucus和属性更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我绑定到我的文本框 ES为:

Currently I bind to my TextBoxes as:

Text="{Binding DocValue,
         Mode=TwoWay,
         ValidatesOnDataErrors=True,
         UpdateSourceTrigger=PropertyChanged}"

本工程在获得每个按键做的按钮状态检查(这是我想要的)伟大的。

This works great in getting every keystroke to do button status checking (which I want).

另外,我想(通过绑定),以追踪在文本框的引发LostFocus 事件,并做一些额外的计算可能是每次击键过于密集。

In addition, I would like to track the LostFocus event on the TextBox (through binding) and do some additional calculations that might be too intensive for each keystroke.

任何人有如何做到既想法?

Anyone have thoughts on how to accomplish both?

推荐答案

我想我已经找到了解决办法...我创建了一个复合命令,并使用了额外的通信。

I think I have found a solution... I created a composite command and use that for the additional communication.

命令定义

 `public static CompositeCommand TextBoxLostFocusCommand = new CompositeCommand();`

我的文本框

    `private void TextboxNumeric_LostFocus(object sender, RoutedEventArgs e)
    {
        if (Commands.TextBoxLostFocusCommand.RegisteredCommands.Count > 0)
        {
            Commands.TextBoxLostFocusCommand.Execute(null);
        }
    }`

然后在我的视图模型,我创建了一个代理指挥和电线把它..

then in my ViewModel, I create a Delegate Command and wire to it..

现在看来似乎是工作,不知道是否有更好的方法。一垮台,这是每一个文本框将触发这一点,不只​​是我的项目附加到的公式我想计算。可能需要想​​办法来改善这一点。

It seems like it is working, wonder if there is a better way. One downfall to this is that every Textbox will fire this, not just my items that are attached to formulas I want to calculate. Might need to think of ways to improve on this.

这篇关于文本框绑定到两个LostFoucus和属性更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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