Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个用户控件,它应该在可见性或启用状态发生变化时触发一个事件。
我的问题是 Visual Studio 的设计器也会触发事件,这很烦人,因为在设计过程中它们会出现意想不到的行为。
我怎样才能防止这种情况?
RaiseEventXYZ将此属性添加到您的(基)类并在orFireEventXYZ方法中检查其值...
RaiseEventXYZ
FireEventXYZ
public class MyClass { public bool IsDesignMode { get;private set; } public MyClass() { IsDesignMode = LicenseManager.UsageMode == LicenseUsageMode.Designtime; } }