123 456 789 0
123 456 789 0

Reputation: 10865

How to execute a function from a Window to another Window?

I have this code in my MainWindow.xaml.cs

Page2 myPage = new Page2();

myPage.ShowData();

Basically, it should implement the function from another class since the function is declared as public and should be accessed by another class, but when I try to execute it it doesn't do anything. It hits the breakpoint but the function is not executed.

In my Page2.xaml.cs I have,

public void ShowData() { textBox1.Text = "Test"; }

Upvotes: 0

Views: 120

Answers (1)

Peter van Kekem
Peter van Kekem

Reputation: 1447

Check whether invocation is required by calling textBox1.InvokeRequired. If that value is true, you've to call textBox1.Invoke([Delegate function]);

Upvotes: 1

Related Questions