I am pretty new in WPF C#. I am held up with the following Issue:
Lets say I have a MainWindow.xaml
, and have the main program logic in it.
I have a second window, called Second.xaml
I am calling Second.xaml
in MainWindow.xaml.cs
,
currently I am doing:
MainWindow.xaml.cs:
var wind = new Second();
wind.Show();
This successfully opens the second window, where I have a few buttons.
My motive is to trigger events in MainWindow
using Second.xaml.cs
(i.e.) in Second.xaml.cs:
....
..
MainWindow mainwindowID = new MainWindow();
....
..
.
private void nextButton_Click(object sender, RoutedEventArgs e)
{
mainwindowID.textBox.Content = "Displaying In Mainwindow";
}
When I click the Next button in Second.xaml
, I want the text Box inside Mainwindow
to be updated.
Though the program in running, nothing changes inside MainWindow
.
Is it possible to control it like that?
I have the MainWindow
displayed using a projector, and the second window on the monitor. So I trigger events inside the second window and want them to be displayed in the MainWindow
.
Is there any other solution for this kind?
Update:
If the textbox is inside SecondPage.xaml
and displayed inside MainWindow.xaml
using a Frame, how do I call it from Second.xaml
?