Silentgamerz
Silentgamerz
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
It would help me a lot
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
Please do
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
do you have any documents or tutorial link for doing that?
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
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
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
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 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;
}


}
Second Window
```public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();


}

private void Button_Click(object sender, RoutedEventArgs e)
{
((MainWindow)this.Owner).Test();
}
}
```public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();


}

private void Button_Click(object sender, RoutedEventArgs e)
{
((MainWindow)this.Owner).Test();
}
}
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
hey I found this code online but i dont really understand how to implement it in my code
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
my head is aching ill try to solve this after a while
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
if my orignal code would work
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
but all this would be not needed
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
yea
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
oh
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
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();

}
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();

}
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
wait let me try and show
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
in the class
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
as for that i would need access to lstbox
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
but i realised it wont work
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
also u were telling about putting code of load list in dbaccess
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
it is showing execption
74 replies
CC#
Created by Silentgamerz on 8/6/2023 in #help
✅ how to call a function from another window WPF
but even after that
74 replies