0

I tried to change the Tab Name like this:

foreach (Window window in Application.Current.Windows)
{
  (window as MainWindow).HomeTab.Header = "Teaching Learning Based Optimization";
}

However all I get is an NullReferenceException. What am I missing?

Patrick Hofman
  • 148,824
  • 21
  • 237
  • 306
Jishan
  • 1,592
  • 3
  • 24
  • 57

2 Answers2

1

P.S. Solved it! Did this:

if (window.GetType() == typeof(MainWindow))
{
  //Code
}

Thanks for the suggestions though.

Jishan
  • 1,592
  • 3
  • 24
  • 57
0

A null check at

(window as MainWindow)
bit
  • 4,271
  • 1
  • 27
  • 47