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 8012569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:21:55+00:00 2026-06-04T19:21:55+00:00

I have a WPF form that takes a list of objects that have locations

  • 0

I have a WPF form that takes a list of objects that have locations and sizes and plots them on the canvas. I’m currently trying to implement an undo button that will throw out all the changes that have been made to the positions of the objects and revert back to the original collection that was retrieved when the form loaded.

As it stands now I go out to the database on the load of the form and get all the objects that will need to be displayed then assign the list that is returned to two seperate collections. The problem that comes up is that the two collections are actually pointers to the original collection and whenever one is changed the changes are reflected in the second collection.

Is it possible to copy a list of objects so that changes made to one collection won’t affect the secondary collection?

So far I’ve tried simply using the assignment operator, passing the source collection into a function byval and scrolling through each element of the list manually adding it to the second collection and using linq to get all the objects from the original list and pushing the results to a separate temporary list and assigning the second collection to the temporary list.

I feel like I’m overcomplicating the issue but almost all the places I’ve come across while googling say that this behavior is by design, which I understand but it seems like this would be a fairly common idea.

  • 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-06-04T19:21:56+00:00Added an answer on June 4, 2026 at 7:21 pm

    Here’s a function I have used before to make “Deep” copies of objects:

    Public Function DeepCopy(ByVal ObjectToCopy As Object) As Object
    
        Using mem as New MemoryStream
    
            Dim bf As New BinaryFormatter
            bf.Serialize(mem, ObjectToCopy)
    
            mem.Seek(0, SeekOrigin.Begin)
    
            Return bf.Deserialize(mem)
    
        End Using
    
    End Function
    

    This is kind of a low level approach compared to some of the other answers, but allows you to deep copy any object. I’ve used it successfully in a situation similar to yours where I needed a deep copy of an array.

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

Sidebar

Related Questions

I have a canvas on my WPF form that I need to run a
I have a WPF form that uses ClientLogin to log a user into their
I have a main wpf form that opens a new form. However when that
I have a WPF form where I'm trying to make a simple input form.
I am creating a WPF form. One of the requirements is that it have
I have a WPF form that contains a DataGrid. This DataGrid is editable. One
I have a menu item on my WPF form that runs an import routine,
I have a form in my WPF application that I have to add an
I have a WPF form with 3 buttons and have routed events on them,
I'm trying to implement elegant form validation in a C# / WPF / Entity

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.