Can't call a method from another window in C# WPF
Ok, let's say I have two windows. In the first one I have a method public void Test() { Label.Content += " works"; } And in the second one I call this method: MainWindow mw = new MainWindow(); mw.Test(); But nothing happens. What am I doing wrong? Thanks. 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