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
  • 153,850
  • 22
  • 249
  • 325
Jishan
  • 1,654
  • 4
  • 28
  • 62

2 Answers2

1

P.S. Solved it! Did this:

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

Thanks for the suggestions though.

Jishan
  • 1,654
  • 4
  • 28
  • 62
0

A null check at

(window as MainWindow)
bit
  • 4,407
  • 1
  • 28
  • 50