private static void SetBehaviors(DependencyObject d, BehaviorBindingCollection value)
        {
            d.SetValue(BehaviorsPropertyKey, value);
            INotifyCollectionChanged collection = value;

            collection.CollectionChanged += CollectionChanged;
        }
        public static BehaviorBindingCollection GetBehaviors(DependencyObject d)
        {
            if (d == null)
            {
                throw new InvalidOperationException("The dependency object trying to attach to is set to null");
            }

            var collection = d.GetValue(BehaviorsProperty) as BehaviorBindingCollection;

            if (collection == null)
            {
                collection = new BehaviorBindingCollection {
                    Owner = d
                };
                SetBehaviors(d, collection);
            }
            return(collection);
        }