I have two windows WPF. The main one contains a grid attached to ObservableCollection<Person>. I can add and remove objects (people) from the list. I also have another window that I can show when I change a person.
A person has three properties: Name, LastName and Age and correctly implements INotifyPropertyChanged. In a new window, I have 3 text fields attached to a static Person resource called "person".
When I initialize a new window, I provide the Person object to the constructor, and then I want the properties of that person to appear in three text windows.
When the code below looks like this, everything works correctly:
public ModifyPerson(Person modPerson)
{
Person p = this.Resources["person"] as Person;
p.Name = modPerson.Name;
p.LastName = modPerson.LastName;
p.Age = modPerson.Age;
}
However, I prefer to do it as follows:
public ModifyPerson(Person modPerson)
{
this.Resources["person"] = modPerson;
}
. ( , modPerson.
?