如果一个属性在设计器中是否显示,需要受到其他一个或几个属性影响,可以通过重写 GetDesignerPropertyVisible 方法实现。
C#示例代码:
public class MyPluginCommand : Command { public bool EnableCache { get; set; } public int CacheTime { get; set; } public override bool GetDesignerPropertyVisible(string propertyName, CommandScope commandScope) { if (propertyName == nameof(CacheTime)) { return EnableCache; } return base.GetDesignerPropertyVisible(propertyName, commandScope); } }
设计器效果: