DesignerProperties.GetIsInDesignMode_ForRealz [How to: Reliably detect Silverlight design mode in Blend and Visual Studio]


This blog has moved to a new location and comments have been disabled.

All old posts, new posts, and comments can be found on The blog of dlaa.me.

See you there!

Comments (3)

  1. In this issue: Chris Cavanagh, David Anson, Walt Ritscher, and Kevin Dockx. Note: The next few days may

  2. Andy Bruce says:

    Here's what I'm using…

       /// <summary>

       /// Are we in design time?

       /// </summary>

       /// <returns></returns>

       public static bool IsDesignTime

       {

         get

         {

           try

           {

             if (System.Windows.Application.Current == null) return true;

             if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(

               System.Windows.Application.Current.RootVisual))

             {

               return true;

             } //if

             var host = System.Windows.Application.Current.Host.Source;

             return false;

           }

           catch

           {

             return true;

           } //try

         } //get

       }