DesignMode Property for WPF

27 February 2007

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. 

Comments:0

Getting a Winform Label to Wrap in a FlowLayoutPanel

10 December 2006
This isn't as obvious as I would have liked for it to have been, but here is how you make a label autosize and wrap appropriately for the text assigned to it when the label is in a Windows Forms FlowLayoutPanel. Set the following properties as you see below:
  • Anchor: Top|Bottom|Left|Right
  • AutoSize: True
  • Dock:None
I found the solution here. Works great.
Comments:0