Click here to Skip to main content
16,020,669 members
Articles / Desktop Programming / WPF
Tip/Trick

Detect Design Time Mode in WPF

Rate me:
Please Sign up or sign in to vote.
4.81/5 (14 votes)
24 Mar 2010CPOL 63.6K   7   6
In order to detect whether your application is executing as a result of being in a designer use the GetIsInDesignMode method of DesignerProperties as the following demonstrate.C#bool designTime = System.ComponentModel.DesignerProperties.GetIsInDesignMode( new...

In order to detect whether your application is executing as a result of being in a designer use the GetIsInDesignMode method of DesignerProperties as the following demonstrate.


C#


C#
bool designTime = System.ComponentModel.DesignerProperties.GetIsInDesignMode(
    new DependencyObject());

VB.NET


VB
dim designTime as Boolean = DesignerProperties.GetIsInDesignMode(
    New DependencyObject)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Engineer
Switzerland Switzerland
Daniel is a former senior engineer in Technology and Research at the Office of the CTO at Microsoft, working on next generation systems.

Previously Daniel was a nine-time Microsoft MVP and co-founder of Outcoder, a Swiss software and consulting company.

Daniel is the author of Windows Phone 8 Unleashed and Windows Phone 7.5 Unleashed, both published by SAMS.

Daniel is the developer behind several acclaimed mobile apps including Surfy Browser for Android and Windows Phone. Daniel is the creator of a number of popular open-source projects, most notably Codon.

Would you like Daniel to bring value to your organisation? Please contact

Blog | Twitter


Xamarin Experts
Windows 10 Experts

Comments and Discussions

 
GeneralMy vote of 5 Pin
zzfima28-Oct-12 21:33
zzfima28-Oct-12 21:33 
thanks
GeneralRe: My vote of 5 Pin
Daniel Vaughan28-Oct-12 23:52
Daniel Vaughan28-Oct-12 23:52 
GeneralMy vote of 5 Pin
thierry_anthony19-Jul-12 6:09
thierry_anthony19-Jul-12 6:09 
GeneralRe: My vote of 5 Pin
Daniel Vaughan28-Oct-12 23:54
Daniel Vaughan28-Oct-12 23:54 
QuestionSolution for Silverlight and WP7 Pin
Nasenbaaer23-Mar-12 10:29
Nasenbaaer23-Mar-12 10:29 
AnswerRe: Solution for Silverlight and WP7 Pin
Pankaj Nikam6-Dec-13 0:11
professionalPankaj Nikam6-Dec-13 0:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.