예제 #1
0
 public static void SetBehaviors(DependencyObject obj, BehaviorCollection value)
 {
     if (obj == null)
     {
         throw new ArgumentNullException("obj");
     }
     obj.SetValue(Interaction.BehaviorsProperty, value);
 }
예제 #2
0
 public static void SetBehaviors(DependencyObject obj, BehaviorCollection value)
 {
     if (obj == null)
     {
         throw new ArgumentNullException("obj");
     }
     obj.SetValue(Interaction.BehaviorsProperty, value);
 }
예제 #3
0
 public static BehaviorCollection GetBehaviors(DependencyObject obj)
 {
     if (obj == null)
     {
         throw new ArgumentNullException("obj");
     }
     BehaviorCollection behaviorCollection = (BehaviorCollection)obj.GetValue(Interaction.BehaviorsProperty);
     if (behaviorCollection == null)
     {
         behaviorCollection = new BehaviorCollection();
         obj.SetValue(Interaction.BehaviorsProperty, behaviorCollection);
     }
     return behaviorCollection;
 }
예제 #4
0
        public static BehaviorCollection GetBehaviors(DependencyObject obj)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }
            BehaviorCollection behaviorCollection = (BehaviorCollection)obj.GetValue(Interaction.BehaviorsProperty);

            if (behaviorCollection == null)
            {
                behaviorCollection = new BehaviorCollection();
                obj.SetValue(Interaction.BehaviorsProperty, behaviorCollection);
            }
            return(behaviorCollection);
        }
예제 #5
0
        private static void OnBehaviorsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            BehaviorCollection behaviorCollection  = (BehaviorCollection)args.OldValue;
            BehaviorCollection behaviorCollection2 = (BehaviorCollection)args.NewValue;

            if (behaviorCollection == behaviorCollection2)
            {
                return;
            }
            if (behaviorCollection != null && behaviorCollection.AssociatedObject != null)
            {
                behaviorCollection.Detach();
            }
            if (behaviorCollection2 != null && sender != null)
            {
                behaviorCollection2.Attach(sender);
            }
        }