private void ButtonClick(object sender, RoutedEventArgs e) { if (_selectedSyncPlusProduct != null) { foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(MainWindow)) { CheckService.BufAddXElm(_selectedSyncPlusProduct.Check.Element("check")); var dg = ((MainWindow)window).GridProducts; dg.DataContext = RepositoryCheck.DocumentProductCheck.Element("check"); CollectionViewSource.GetDefaultView(dg.ItemsSource).Refresh(); Close(); CheckService.SaveEnAttenete(_selectedSyncPlusProduct.CustomerId); } } } }