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. 

Filed Under: Winforms WPF

Comments: 0

Comments

Something To Say?

Name: (optional)
Email: (optional, and will not be displayed)
Website: (optional)
Comment:

You can use html tags like <b>, <a>, and <p>. Actually, you can use just about anything. If you want to see what it will look like, click the preview comment button below.