简体   繁体   中英

wpf textBox Text Changed event

A table contains ID, Name, Job in database and 3 textboxes on wpf window. I want, when ID textbox change, fills two other textboxes from database. I only can do it with comboBox_SelectionChanged.

You can use MVVM pattern to accomplish the same. I will try to explain the involved steps in brief.

  1. Create a VM(View Model) class and inherit the same from INotifyPropertyChanged.
  2. Implement the PropertyChanged event.
  3. Define a function that will Notify the property changes. This function will be called by Set accessor of each property that needs notification whenever a property changes.
  4. Declare three properties namely ID, Name and Job inside the class. Bind each of the properties with their respective textbox controls. Inside the ID property, set the value of other two controls.

Use the link below for better understanding.

http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx

你可以将TextChanged事件用于文本框。将id值与database.if中的值进行比较。如果等于,则通过数据库检索该id的相应名称和作业

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM