TriggerAction and Custom Controls

TriggerAction and Custom Controls

Old forum URL: forums.lhotka.net/forums/t/10017.aspx


bastidas posted on Wednesday, February 02, 2011

Hello

Does the TriggerAction require the custom controls to be derived from FrameworkElement? I'm using a custom control that derives from FrameworkContentElement and I can't get the Trigger to work on the element's click Event.

If that's the case, what work around can anyone recommend when facing this situation?

Thank you
Andres

RockfordLhotka replied on Wednesday, February 02, 2011

Yes, TriggerAction requires that the control derive from FrameworkElement.

I suppose it could go up one level to UIElement.

What is the base class for FrameworkContentElement?

bastidas replied on Wednesday, February 02, 2011

"I suppose it could go up one level to UIElement."

Is this something I have to do on my code or a change you might do on TriggerAcction?

System.Windows.FrameworkContentElement's base clase is System.Windows.ContentElement which derives from System.Windows.DependencyObject which is, at last, where FrameworkContentElement and FrameworkElement find a common ancestor.

Andres

RockfordLhotka replied on Wednesday, February 02, 2011

There is code in TriggerAction that currently expects the FrameworkElement type.

I don't know for certain that this can be just changed to DependencyObject, or what the impact might be in such a change. I don't see an obvious problem though.

You could edit TriggerAction to change the FrameworkElement type to DependencyObject in the TargetControl property implementation and the HookEvent method to see if this causes any problems, and to see if it solves your issue.

Copyright (c) Marimer LLC