Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF GetIsInDesignMode From Inside A Converter

How would i be able to use the GetIsInDesignMode from inside a converter? It seems that the method requires the parent user control/window, a variable which is not accessible when inside a converter.

Example :

public class CellImageConverter : IValueConverter
{
      public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
      {
          if (DesignerProperties.GetIsInDesignMode(??))
          ..
          ..

Thanks

like image 729
OrPaz Avatar asked Feb 14 '11 16:02

OrPaz


1 Answers

I came across a few answers searching for "DesignerProperties wpf". This method from http://sweux.com/blogs/laranjeira/index.php/wpf/design-mode-wpf/how-to-get-design-mode-property-in-wpf/ is quite simple.

DesignerProperties.GetIsInDesignMode(new DependencyObject());
like image 169
Kris Avatar answered Nov 09 '22 01:11

Kris