The WPF mystery

time to read 1 min | 113 words

Okay, here are a few weird things that I wish I didn't know about WPF.

  • It does some low level cheating all over the place, for fun & profit, put the following like in the main window ctor:
    	Debug.Assert(Application.Current.MainWindow != this); 
    Remember that on the CLR, you don't often see other objects referencing before you even started your constructor.
  • Then there is this fun puzzle, when I am registering to the Application.Startup event, I am getting inconsistent results with regards to Application.MainWindow being null or not. After a short investigation, I pinned the blame on the async initialization of the windows. But it was a major PITA, to say the least.