Triggers are attachable objects that encapsulate some logic to determine when they are activated. They execute their associated action whenever they are activated.
Inheritance: System.Windows.FrameworkElement, IAttachedObject
        private static int GetIndexOf(BehaviorCollection itemBehaviors, Behavior behavior)
        {
            int index = -1;

            Behavior orignalBehavior = GetOriginalBehavior(behavior);

            for (int i = 0; i < itemBehaviors.Count; i++)
            {
                Behavior currentBehavior = itemBehaviors[i];

                if (currentBehavior == behavior
                    || currentBehavior == orignalBehavior)
                {
                    index = i;
                    break;
                }

                Behavior currentOrignalBehavior = GetOriginalBehavior(currentBehavior);

                if (currentOrignalBehavior == behavior
                    || currentOrignalBehavior == orignalBehavior)
                {
                    index = i;
                    break;
                }
            }

            return index;
        }
Beispiel #2
0
        private static int GetIndexOf(BehaviorCollection itemBehaviors, Behavior behavior)
        {
            var index = -1;

            var orignalBehavior = GetOriginalBehavior(behavior);

            for (var i = 0; i < itemBehaviors.Count; i++)
            {
                Behavior currentBehavior = itemBehaviors[i];

                if (Equals(currentBehavior, behavior)
                    || Equals(currentBehavior, orignalBehavior))
                {
                    index = i;
                    break;
                }

                Behavior currentOrignalBehavior = GetOriginalBehavior(currentBehavior);

                if (Equals(currentOrignalBehavior, behavior)
                    || Equals(currentOrignalBehavior, orignalBehavior))
                {
                    index = i;
                    break;
                }
            }

            return index;
        }
        public void WriteBehavior(Behavior behavior)
        {
            if (behavior == null)
                return;

            writer.WriteStartElement(behavior.GetType().Name, Constants.esriBehaviorsNamespace);
            WriteObjectPropertiesAsAttributes(writer, behavior);
            writer.WriteEndElement();
        }
Beispiel #4
0
        protected override void OnAttached()
        {
            System.Windows.Interactivity.Behavior behavior = base.AssociatedObject as System.Windows.Interactivity.Behavior;
            FrameworkElement associatedElement             = base.AssociatedObject as FrameworkElement; if (behavior != null)

            {
                associatedElement = ((IAttachedObject)behavior).AssociatedObject as FrameworkElement;
            }
            if (associatedElement == null)
            {
                throw new ArgumentException("Routed Event trigger can only be associated to framework elements");
            }
            if (RoutedEvent != null)
            {
                associatedElement.AddHandler(RoutedEvent, new RoutedEventHandler(this.OnRoutedEvent));
            }
        }
 private static void SetOriginalBehavior(DependencyObject obj, Behavior value)
 {
     obj.SetValue(OriginalBehaviorProperty, value);
 }