Click here to Skip to main content
15,903,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm deserializing the saved textbox properties and assigning to the textbox. Textbox properties are getting updated with new values but not the UI (WPF).

below is the snippet.
C#
textbox1 = (TextBox) new XmlObjectSerializer().Deserialize(File.ReadAllText(@"WPFUISerialization.Xml"));

Thank You,
Vireen
Posted
Updated 21-Mar-15 22:22pm
v3

1 solution

Assuming that textbox1 holds a reference to the wanted TextBox, that TextBox is also held by the UI tree (and this is what the UI shows...). When you change the value of textbox1 it is changed only in that variable and, changes nothing in the UI.


If you want to change the UI, you can load the TextBox to another variable and, change the wanted values in the UI's TextBox. Something like:


C#
TextBox tb = (TextBox) new XmlObjectSerializer().Deserialize(File.ReadAllText(@"WPFUISerialization.Xml"));

textbox1.Text = tb.Text;
// ...
 
Share this answer
 
Comments
Vireen 22-Mar-15 7:44am    
let me give more details.. I'm saving roperties of the textbox (text wrapping, text, startindex etc.,) and serialize into xml before closing the application containing this textbox. When application is reopened I will be reading previously saved textbox properties from the xml (object typecast to textbox) and apply it to the textbox.
Assigning each property explicitly may not be effective.

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