Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a DesignMode property in WPF?

Tags:

.net-3.5

wpf

In Winforms you can say

if ( DesignMode ) {   // Do something that only happens on Design mode } 

is there something like this in WPF?

like image 501
Russ Avatar asked Jan 08 '09 20:01

Russ


1 Answers

Indeed there is:

System.ComponentModel.DesignerProperties.GetIsInDesignMode

Example:

using System.ComponentModel; using System.Windows; using System.Windows.Controls;  public class MyUserControl : UserControl {     public MyUserControl()     {         if (DesignerProperties.GetIsInDesignMode(this))         {             // Design-mode specific functionality         }     } } 
like image 93
Enrico Campidoglio Avatar answered Oct 04 '22 23:10

Enrico Campidoglio