在WPF中是否有DesignMode属性?

在Winforms你可以说

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

在WPF中有这样的东西吗?

实际上有:

System.ComponentModel.DesignerProperties.GetIsInDesignMode

例:

using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;

public class MyUserControl : UserControl
{
    public MyUserControl()
    {
        if (DesignerProperties.GetIsInDesignMode(this))
        {
            // Design-mode specific functionality
        }
    }
}

转载注明原文:在WPF中是否有DesignMode属性? - 代码日志