I do have a public void grid_refresh()
Method in my Main Window which refreshes my DataGrid (Main Window's DataGrid). Now I do have another class (Window) which adds new elements to the Datagrid. The thing I don't get done is to access this grid_refresh
Method to refresh the grid with the new entries when I hit the Add Button from my other window (Add Window).
Main Window Code:
Method to open up the AddBook Window:
private void AddBuch(object sender, RoutedEventArgs e)
{
if (Title == "Dictionary")
{
MessageBox.Show("Wählen Sie zuerst unter Ansicht eine Kategorie aus!");
}
else
{
addBuch addbuch = new addBuch(this);
addbuch.Show();
//do { } while (addbuch.ShowDialog() == true);
}
}
The method I want to get access to:
public void liste_aktualisieren()
The Window Code I want to access the Method from:
public partial class addBuch : Window
{
private MainWindow mainWindow;
public addBuch(Window owner)
{
InitializeComponent();
Owner = owner;
SetProperties();
owner.IsEnabled = false;
}
private void btn_add_Click(object sender, RoutedEventArgs e)
{
if (txt_name.Text == "" | txt_isbn.Text == "" | txt_datum.Text == "" | txt_genre.Text == "" | txt_autor.Text == "" | txt_seiten.Text == "")
{
MessageBox.Show("Es sollte allen Feldern ein Wert zugewiesen werden.\nVersuchen Sie es erneut!");
}
else
{
cDictionary.Buch_hinzufuegen(txt_name.Text, txt_isbn.Text, txt_datum.Text, txt_genre.Text, txt_autor.Text, Convert.ToInt32(txt_seiten.Text));
Owner.IsEnabled = true;
//Somewhere here I want to Acess the DataGrid Refresh Method so the Datagrid in the Main Window Refreshes.
}
}
I am not really sure how to get around this... My intention is to refresh the Datagrid the Moment the btn_add_Click is pressed