附加属性的不同使用方式

原文: 附加属性的不同使用方式

    [AttachedPropertyBrowsableForType(typeof(ButtonBase))]
      public static void SetIsClearTextButtonBehaviorEnabled(Button obj, bool value)
       {
           obj.SetValue(IsClearTextButtonBehaviorEnabledProperty, value);
       }    
      public static void SetIsClearTextButtonBehaviorEnabled(DependencyObject obj, bool value)
       {
           obj.SetValue(IsClearTextButtonBehaviorEnabledProperty, value);
       }

      1.一旦将设置方法的第一个参数修改为某个控件,则只能适用于自己,DependencyObject适用于全部

      2.AttachedPropertyBrowsableForType 专供某类型访问

猜你喜欢

转载自www.cnblogs.com/lonelyxmas/p/10004264.html