在WPF中一个DesignMode属性? [英] Is there a DesignMode property in WPF?
本文介绍了在WPF中一个DesignMode属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在的WinForms,你可以说
In Winforms you can say
if ( DesignMode )
{
// Do something that only happens on Design mode
}
有没有这样的事情在WPF?
is there something like this in WPF?
推荐答案
的确有
<一个href="http://msdn.microsoft.com/en-us/library/system.componentmodel.designerproperties.getisindesignmode.aspx">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属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文