Skip to content

动态隐藏属性

如果一个属性在设计器中是否显示,需要受到其他一个或几个属性影响,可以通过重写 GetDesignerPropertyVisible 方法实现

C#示例代码

csharp
    public class MyPluginCellType : CellType
    {
        public bool EnableCache { get; set; }
        public int CacheTime { get; set; }
        public override bool GetDesignerPropertyVisible(string propertyName)
        {
            if(propertyName == nameof(CacheTime))
            {
                return EnableCache;
            }
            return base.GetDesignerPropertyVisible(propertyName);
        }
    }

设计器效果

1669964741305-5723590b-7770-4ec3-8eca-3f91ee8dee34.gif

更新: 2022-12-02 15:05:54
原文: https://www.yuque.com/robert-bh51n/ea8l6c/eill1gcvtranf0v0