private static void OnTemplateChanged(
            DependencyObject d,
            DependencyPropertyChangedEventArgs e)
        {
            var dt = (InteractivityTemplate)e.NewValue;

#if (!SILVERLIGHT)
            dt.Seal();
#endif
            var ih = (InteractivityItemsAttached)dt.LoadContent();
            var bc = Microsoft.Xaml.Behaviors.Interaction.GetBehaviors(d);
            Microsoft.Xaml.Behaviors.TriggerCollection tc = Microsoft.Xaml.Behaviors.Interaction.GetTriggers(d);

            foreach (var behavior in ih.Behaviors)
            {
                bc.Add(behavior);
            }

            foreach (var trigger in ih.Triggers)
            {
                tc.Add(trigger);
            }
        }
Ejemplo n.º 2
0
        private static void OnTriggersChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            StyleTriggerCollection styleTriggers = e.NewValue as StyleTriggerCollection;

            if (styleTriggers != null)
            {
                Microsoft.Xaml.Behaviors.TriggerCollection triggers =
                    Microsoft.Xaml.Behaviors.Interaction.GetTriggers(d);

                foreach (Microsoft.Xaml.Behaviors.TriggerBase trigger in styleTriggers)
                {
                    Microsoft.Xaml.Behaviors.TriggerBase triggerClone =
                        (Microsoft.Xaml.Behaviors.TriggerBase)trigger.Clone();

                    foreach (Microsoft.Xaml.Behaviors.TriggerAction action in trigger.Actions)
                    {
                        triggerClone.Actions.Add((Microsoft.Xaml.Behaviors.TriggerAction)action.Clone());
                    }

                    triggers.Add(triggerClone);
                }
            }
        }