DesignMode Property for WPF
Posted: 02/27/07 11:34 PM
A very useful property for visual elements that you wanted to use in a designer in Visual Studio in Winform development was the DesignMode property of Component. That allowed you to make conditional code that wouldn't have the proper context to run in a design mode environment.
It is not immediately obvious how to do that in WPF, because it doesn't show up in the intellisense where you would expect it. But, it is still there. It is a little less convenient, but no worries. A check would look something like this:
bool foo = System.ComponentModel.DesignerProperties.GetIsInDesignMode(this);
That boolean value would indicate whether or not you were in design mode. A lot more verbose, but still workable.