在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
        }
    }
}
http://stackoverflow.com/questions/425760/is-there-a-designmode-property-in-wpf

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:在WPF中是否有DesignMode属性?