I add a TextBlock
to the MainWindow in XAML. And I would need to change the TextBlock Text in a separate class resided in a separate .cs file. I tried the following
To answer my question - use internal
instead of public
.
// in MainWindow.xaml.cs internal internal static fooNameSpace.MainWindow tW1; // in foo.cs MainWindow.tW1.txtBlock1.Text = "This is a paragraph";
the internal keyword allows other class in other cs file to get access to MainWindow controls. But I'm not so sure about using internal to solve this problem as it allow my other class to get access to everything else in my MainWindow...any better option out there?