Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6958263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:07:01+00:00 2026-05-27T15:07:01+00:00

What I did before was make a deep copy of the data object, then

  • 0

What I did before was make a deep copy of the data object, then write a generic compare method that uses reflector to compares if there is difference betweens the two objects.

So say if I have a SaveButton, a TextBoxA binded with a ViewModel.PropertyA, initialy PropertyA is = “123”.

When user typed “1234” in TextBoxA, the PropertyA set method will executes the compare method to find the difference. And enable the Save Button.

But when the user changed the text “1234” back to “123”, the Save button will disabled again.

After 1 year, now I wonder is there a better way or easier way to do it?
i.e. Is there any framework that will do this kind of stuff? So I don’t have write code for deep copy the object, write compares method myself?


The actual UI I had was not that simple only contains TextBox type, that was a UI for edit customer information, thus have DateTime, Collection etc. That’s why I wrote deep copy method for cloning the whole object.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:07:02+00:00Added an answer on May 27, 2026 at 3:07 pm

    Assuming that these properties on your View Model are raising the PropertyChanged event somehow since the question is tagged with MVVM.

    Here’s one approach. Write an event handler for your ViewModel’s PropertyChanged event. Save original values in a private Dictionary<string, string> only when a property changes. That prevents the need for copying the whole object just in case someone makes an edit. If the property already exists in the dictionary, then you could easily determine if it’s been changed back to its original value.

    Edit: Oh, I was thinking that the PropertyChangedEventArgs contained new and old values, but it doesn’t. So, in order to do this, you’d need to add some extra method call within your View Model’s property setters that can evaluate the old and new values of each property.

    In order to easily set up enabling and disabling the Save button, there should be a bool property in your view model to which you would bind the Save button’s enabled property.

    If items are removed from the dictionary whenever the new value matches the original value, then your Save button enabled property could just return true if the dictionary contains any items.

    Edit 2: For the collection types, you’d want to have your View bind to ObservableCollection properties on your View Model. The Collection changed event does give you a list of old and new items, so keeping track of the changes within that event handler should be fairly easy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I did it before... But I forgot. I have a file with some data:
Please note that this is not homework and i did search before starting this
Before someone said that I did not read I may say that I read
I did this before with javascript, and have no idea to make it using
I have a method that will provide an array of model object. Some of
I used before setListAdapter with simple_multiple_choice to make listview with checkboxes. And then I
I know that this question is being asked before but I did not get
I did my programming before integrating into a design and I have to admit
Did you used Dynamic websites before? you see its a good way for making
I never did any serious Java coding before, but I learned the syntax, libraries,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.