WPF MVVM textbox text binding vs changedText event

前端 未结 1 642
一整个雨季
一整个雨季 2020-12-15 21:16

I have textbox with Text property binded to viewmodel. I have binded TextChanged event to viewmodel.

But the problem is that the event fires every sign is added to t

相关标签:
1条回答
  • 2020-12-15 22:00

    There is a really simple answer to this; use UpdatePropertyTrigger=PropertyChanged. This will update your VM property each time a character is changed. No need for triggers or commands :-)

    <TextBox Text="{Binding ViewModelProperty, UpdateSourceTrigger=PropertyChanged}"></TextBox>
    

    Read here for more info: http://msdn.microsoft.com/en-us/library/system.windows.data.updatesourcetrigger(v=vs.110).aspx

    0 讨论(0)
提交回复
热议问题