private void btnAdd_Click(object sender, RoutedEventArgs e) { AddCountry countryDialog = new AddCountry(); AddCountryViewModel countryDialogVm = new AddCountryViewModel(); countryDialogVm.CancelCommand = new RelayCommand(() => { countryDialog.Close(); }); countryDialogVm.OKCommand = new RelayCommand(() => { if (countryDialogVm.IsValid) { DataProvider dp = new DataProvider(); City ci = dp.AddCoutryWithCity(countryDialogVm.CountryName, countryDialogVm.CityName); context.Countries.Load(); context.Cities.Load(); myCountriesViewSource.View.Refresh(); countryDialog.Close(); Messenger.Default.Send <string>(Utils.CountryAddedMessage); } else { countryDialogVm.UserMessage = "Please Complete Info "; } }); countryDialog.DataContext = countryDialogVm; countryDialog.ShowDialog(); }