开发者

Can you suggest similr event for TextChange event of a TextBox in .Net WPF

开发者 https://www.devze.com 2023-03-17 02:56 出处:网络
I have to do complex calculations on every textchange 开发者_如何学编程event of a WPF textbox , Is there any similar event ?you can make use of Binding for that and make sure sure any change to the bo

I have to do complex calculations on every textchange 开发者_如何学编程event of a WPF textbox , Is there any similar event ?


you can make use of Binding for that and make sure sure any change to the bound item gets triggered:

<TextBox Text="{Binding Path=X, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

and then in your viewModel you can do calculations based on that change (your ViewModel should implement INotifyPropertyChanged:

public int MyProperty
        {
            get
            {
                return myVar ;
            }
            set
            {
                myVar = value;
                OnPropertyChanged("MyProperty") ;

                //Fire off calculation in another thread in here

            }
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号