I have two WPF windows. Main one contains a grid bound to ObservableCollection<Person>
. I can add and remove objects (people) from the list. I also have another window that I can show when I modify a person.
Person has three properties: Name, LastName and Age and properly implements INotifyPropertyChanged. In the new window I have 3 textboxes that are bound to a static resource Person called "person".
When I initialize new window I provide Person object to the constructor and then I want this person properties to be shown in the three textboxes.
When the code below looks like this everything works properly:
public ModifyPerson(Person modPerson)
{
// ... some code
Person p = this.Resources["person"] as Person;
p.Name = modPerson.Name;
p.LastName = modPerson.LastName;
p.Age = modPerson.Age;
}
However I prefer doing it like this:
public ModifyPerson(Person modPerson)
{
// ... some code
this.Resources["person"] = modPerson;
}
But then it does not work. (The resource is assigned properly, but the textboxes do not present the values of modPerson properties.
How can that be solved?