private void BtnSavecategory(object sender, RoutedEventArgs e) { if (!txtCatId.Text.Equals("")) { Category c = new Category(); c.CategoryID = Int32.Parse(txtCatId.Text); c.CategoryName = txtCatName.Text; c.Description = txtDescri.Text; da.EditCategory(c); MessageBox.Show("Category Updated"); MainWindow mw = Application.Current.Windows.OfType <MainWindow>().FirstOrDefault(); if (mw != null) { mw.MainFrame.Content = new ManageCategories(); } } }