Mike Fulton
Mike Fulton

Reputation: 918

How to access System.ComponentModel.DesignProperties?

I have a user control in my project that crashes at design-time when I try to add it to a form, so I want to add in a check to see if we're at design time. From what I've read, that's done by calling the function:

System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)

from the user control. The problem I'm having is that VS2013 is telling me that "DesignProperties" does not exist in the current context.

I've got "using System.ComponentModel" in there, so I dunno what's wrong. Any ideas?

Upvotes: 0

Views: 439

Answers (1)

Milan Raval
Milan Raval

Reputation: 1890

It is for WPF and DesignerProperties is found only in PresentationFramework (in PresentationFramework.dll), where the parameter passed to the GetIsInDesignMode is a System.Windows.DependencyObject

For WinForms you can check it with

if (!DesignMode)

Upvotes: 1

Related Questions