2

I have a Wpf Textbox control is used for billing app. I entered a price in textbox, the calculation is done on every entered character for text changed event. And I tried Lost focus event, Some times I don't want to modify price but lost focus event was fired when focus on textbox. I want the event for text changed and edit is finished, How to rectify this prob.. Plz reply.. and thankz.,

  • 1
    Please provide code you have written? – Vaibhav Mule Apr 19 '16 at 05:04
  • Don't what you want to achieve, but what you are asking for is not part of WPF. What you instead could try is IDataErrorInfo and Validation. See this here: http://stackoverflow.com/questions/19539492/wpf-textbox-validation-c-sharp/19546780#19546780 and here for more info https://tarundotnet.wordpress.com/2011/03/03/wpf-tutorial-how-to-use-idataerrorinfo-in-wpf/ – Nawed Nabi Zada Apr 19 '16 at 05:19
  • 2
    What I would suggest you is to use Binding instead of Events (TextChanged and LostFocus). You can achieve both the behaviour by changing the UpdateSourceTrigger to either LostFocus or PropertyChanged and the set method in your property will hit only when the value is actually changed. So you can avoid unnecessary calculation or whatever... https://msdn.microsoft.com/en-us/library/system.windows.data.updatesourcetrigger(v=vs.110).aspx – Davy Apr 19 '16 at 05:32
  • _Some times I don't want to modify price_ . Can you mention when you do not want? – Gopichandar Apr 19 '16 at 06:08

0 Answers0