Пример #1
0
        public void can_attach_a_trigger_to_a_ui_element()
        {
            var dp      = new Button();
            var trigger = Mock <IMessageTrigger>();

            trigger.Expect(x => x.Attach(Arg <InteractionNode> .Is.NotNull));

            controller.AttachTrigger(
                dp,
                trigger
                );

            var node = dp.GetValue(DefaultRoutedMessageController.NodeProperty) as InteractionNode;

            node.ShouldNotBeNull();
            node.Triggers.Contains(trigger).ShouldBeTrue();
        }
Пример #2
0
        private static void OnTriggersChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (_controller == null)
            {
                return;
            }

            if (e.NewValue != e.OldValue)
            {
                var triggers = e.NewValue as RoutedMessageTriggerCollection;

                if (triggers != null)
                {
                    foreach (var messageTrigger in triggers)
                    {
                        _controller.AttachTrigger(d, messageTrigger);
                    }
                }
            }
        }