Search code examples
c#wpfxamldata-bindingbinding

WPF Binding - Changing property on one object in collection and all the objects are changing


When I change value of textbox or checkbox it changes in every line. Whats wrong? Here is an examplу: All checkboxes aren't checked. I click on one of them and all the other are now checked.

enter image description here

Here is the code: enter image description here

enter image description here

Adding position method: enter image description here


Solution

  • The problem is because of the below line

    spotPosition = AutoTradingPositions.Where(position => 
                              position.PositionNumber == latestPositionNumber).First();
    

    Where you are getting the same instance (first item in the collection) and adding the same as other items to the collection.