附加属性的不同使用方式

    [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 专供某类型访问

posted @ 2018-11-22 14:14  Index_Zero  阅读(218)  评论(0编辑  收藏  举报