Storing Original Values of Form using Silverlight MVVM RRS feed

  • Question

  • I am facing a problem storing original values of a form.

    I have a form with number of Text boxes.All these textboxes binds with a single Entity. For e.g.

    Class Car 

         private int Light; 
         private int TailLight; 
         private int Seats; 
         private int Gears; 

    Now one text box will bind with Light, one with TailLight and so on.

    On page load these text boxes are filled with some values, and user has an option to edit these text boxes and save the data. Now before saving these data i need to check the OriginalValues (on pageload) with the edited values. I am not able to find a way to store these original values anywhere. No matter where i save the original values the data get changed to the edited value at the end, i understand this is because we are giving reference.

    Can anybody suggest a way to solve this......

    Tuesday, November 22, 2011 9:06 AM


  • I am not sure what your specific scenario is, but if you load the text box values as part of the page initialization, you should be able to create an instance of the class that can be used to hold the original data.

    In your example, you don't show any getters/setters, binding, etc. Do you have more detailed code than shown above?

    E.g., I will assume you have a class with the appropriate getters/setters.

    You could do something along the lines of:

    private Car originalCarValues;

    void Page_Loaded(object sender, RoutedEventArgs e)



       originalCarValues = new Car();

       originalCarValues.Light = Light;

       originalCarValues.TailLight = TailLight;

       originalCarValues.Seats = Seats;

       originalCarValues.Gears= Gears;


    Make sure that the text box values are loaded prior to initializing your originalCarValues instance.


    Tuesday, November 22, 2011 12:04 PM