I found the solution,
first I modify the ViewModel:
private void add(object obj)
{
Add addView = new Add();
addView.DataContext = new ViewModelADD(addView,loadDataBinding);
addView.Show();
}
then i modify the ViewModelADD:
<pre> private readonly Window _window;
private readonly ObservableCollection<Custmor> _loadDataBinding;
public ViewModelADD(Window window,ObservableCollection<Custmor> loadDataBinding)
{
CustomerToAddObject = new Custmor();
addCustomer1 = new RelayCommand(ADDFunction);
_window = window;
_loadDataBinding = loadDataBinding;
}
private void ADDFunction(object obj)
{
using (Test1Entities context = new Test1Entities())
{
context.Custmor.Add(customerToAddObject);
context.SaveChanges();
MessageBox.Show("Customer a été ajouté avec succès!");
}
_loadDataBinding.Add(customerToAddObject);
_window.Close();
}
It works correct now,