Click here to Skip to main content
15,881,866 members
Please Sign up or sign in to vote.
4.33/5 (3 votes)
See more:
Hi!
I am newcomer in wpf. Plz help me in this regard.
In MFC we updates controls(e.g textbox)with Update(True) or Update(False). How we do in WPF?
I take two textbox with name firstTextBox and secondTextBox.Now i want that user inputs two integer from keyboard in two textboxes and on clicking of a button (say AddButton) my application add them and display the result in third textbox i.e, thirdTextBox (Three textboxes and one button were taken on a canvas with name myCanvas). What will be the code in WPF?

regards
Posted

1 solution

This question has nothing to do with Update. With .NET controls (not only for WPF, and not even only for UI), you don't need any special updating, because all required invalidation of the presentation of the controls are performed through their properties. When a property value is changed, the code of the property setter invokes required side effect of property assignment.

In case of System.Windows.Controls.TextBox, it is updated by assignment a value to its property string Text (in particular).

Please see: http://msdn.microsoft.com/en-us/library/system.windows.controls.textbox.aspx[^].

This property is all you need to solve the problem. Also, as the property is of the string type, and you need to work with int, you will need to parse a string to an integer value and present the integer value as a string, so you will need to use int.Parse (throws exception in case of invalid numeric format) or int.TryParse (returns Boolean value depending on success) and int.ToString.

Now, that's really all you need.

—SA
 
Share this answer
 
Comments
Amir Mahfoozi 27-Mar-12 3:47am    
+5
Sergey Alexandrovich Kryukov 27-Mar-12 23:04pm    
Thank you, Amir.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900