You can assign the Owner to the window that was created in your MainWindow.window.Owner = this; //This is added to the code that use to create your Window
Then you should be able to access it something like this.((MainWindow)this.Owner).Test();MainWindow
public partial class MainWindow : Window{ Window1 window = new Window1(); public MainWindow() { InitializeComponent(); window.Show(); } public void Test() { label1.Content += " works"; } private void Window_Loaded(object sender, RoutedEventArgs e) { window.Owner = this; }}
```public partial class Window1 : Window{ public Window1() { InitializeComponent(); } private void Button_Click(object sender, RoutedEventArgs e) { ((MainWindow)this.Owner).Test(); }}
public void LoadList() { ManageStock manageStock = new ManageStock(); DataTable dt = new DataTable(); string query = "select * from DesignTB"; readDatathroughAdapter(query, dt); manageStock.lstBox.ItemsSource = dt.DefaultView; closeConn(); }