Designer exception

Nov 23, 2010 at 4:07 PM

 

When opening the demo project(Main.xaml) i get this when using the designer:

at WPF.MDI.MdiContainer.MdiContainer_Loaded(Object sender, RoutedEventArgs e) in C:\Users\luka.ONYX\Desktop\WPF.MDI\WPF.MDI\MdiContainer.cs:line 114


System.NullReferenceException

Object reference not set to an instance of an object.

 

the project works when compiled but...this is annoying since it happens if you only add the mdicontainer to a project.makes the designer unusable.any ideas how to fix this?

Nov 23, 2010 at 4:09 PM
Edited Nov 23, 2010 at 4:11 PM
bool designTime = System.ComponentModel.DesignerProperties.GetIsInDesignMode(new DependencyObject());
            if(!designTime)
            {
                Window.GetWindow(this).Activated += new EventHandler(MdiContainer_Activated);
                Window.GetWindow(this).Deactivated += new EventHandler(MdiContainer_Deactivated);
            }
fixes it.