Click here to Skip to main content
14,298,693 members
Rate this:
Please Sign up or sign in to vote.
See more:
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?


1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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:[^].

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.

Amir Mahfoozi 27-Mar-12 3:47am
Sergey Alexandrovich Kryukov 27-Mar-12 23:04pm
Thank you, Amir.

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100