私はObservableCollection<Customer>
私の窓にいます。
ObservableCollection<Customer> customers = new ObservableCollection<Customer>();
public ObservableCollection<Customer> Customers { get { return customers; } set { customers = value; OnPropertyChanged("Customers"); } }
これObservableCollection
はウィンドウにバインドさListView
れています。[顧客の選択]を使用してlistView
[編集]をクリックすると、選択した顧客のデータを含む新しいウィンドウが表示されます。
2番目のウィンドウのコンストラクタ
public EditCustomerWindow(Customer c)
{
InitializeComponent();
customerobj = c; //Original object
tempCustomerobj = new Customer(c); //Getting a copy of the customer object
CustomerDataGrid.DataContext = tempCustomerobj;
}
ユーザーが[保存]ボタンをクリックすると、顧客オブジェクトが更新され、ウィンドウが閉じます。
しかし、私の問題は、ObserverCollection
編集ウィンドウが閉じる前に新しい編集済み顧客オブジェクトを設定しても、最初のウィンドウで更新が行われないことです。私がしていることが何が間違っているのかわかりません。アドバイスしてください。
customerobj = tempCustomerobj;