Thursday, December 17, 2009

Detecting Design Mode in WPF controls

Who would've thought that it would be difficult to find information on detecting Design mode in WPF controls.  In Winforms, there is a simple DesignMode boolean property you can check, but it's not so obvious in WPF, plus Bing searches gave convoluted answers (you know, the kind of answer you get from a know-it-all geek), although the answer was there.
 
So here's the beef:
 
System.ComponentModel.DesignerProperties.GetIsInDesignMode(this);
 
This returns a boolean, and "this" is your UserControl or something that is a DependencyObject.

No comments:

Post a Comment