locked
EventTrigger question RRS feed

  • Question

  • Hi,

    I've started implementing my own InvokeDelegateCommand trigger action which will invoke Prism delegate command and have a problem with EventTrigger.

    Event trigger doesn't invoke actions if control is dynamically created.

    Here is code sample of test (Invoke method of InvokeDelegateCommandAction is not called).

            [TestMethod]
            public void Test()
            {
                var button = new ClickableObjectMock();
                var eventTrigger = new EventTrigger("Click");
                var triggers = Interaction.GetTriggers(button);
                triggers.Add(eventTrigger);
    
                eventTrigger.Actions.Add(new InvokeDelegateCommandAction());
             
                button.RaiseClick();
            }
    If i will do the same with control, which is present in visual tree everything works correct. For example I will recieve button instance in code behind of user control.

    Thanks,
    Alexey Zakharov
    Thursday, August 6, 2009 9:39 AM

Answers

  • To fix the problem TestClass should be inherited from PresentationTest. That will allow to place button in special test panel container:

    TestPanel.Children.Add(button)
    Thursday, August 6, 2009 10:00 AM