In my App class, I have a Collection of objects, like this: (the Collection is in the App class because i need to have access to it application-wide in different windows, etc.)
public partial class App : Application
{
public ObservableCollection<Person> Persons { get; set; }
public App()
{
Persons = new ObservableCollection<Person>();
Persons.Add(new Person() { Name = "Tim", Age = 20 });
Persons.Add(new Person() { Name = "Sarah", Age = 30 });
}
}
public class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
On the main window of the application, there is a ComboBox binding to the Persons Collection:
<ComboBox ItemsSource="{Binding Source={x:Static Application.Current}, Path=Persons}" DisplayMemberPath="Name"/>
Now I want to create a dialog, in which the user is able to add/remove/edit persons with the well known OK/Cancel button behavior. Can this be down easily? One important thing is that the items in the ComboBox must not be effected by the changes the user is making before pressing OK.
Thanks in advance!
Edit: I think I should point out that I don't want to edit a specific person in the dialog, but the whole list of persons.