dotnet/wpf · error · InvalidOperationException
SR.EventTriggerDoesNotEnterExit
Error message
SR.EventTriggerDoesNotEnterExit
What it means
EventTrigger.Seal() throws if EnterActions or ExitActions are set. These collections are only meaningful on property-based triggers (Trigger/MultiTrigger), where they fire when a condition becomes true/false. On an EventTrigger they have no semantics, so the library rejects them.
Solutions
- Move the actions into the EventTrigger's Actions collection (executed when the event fires).
- If enter/exit semantics are needed, use a property Trigger with EnterActions/ExitActions instead.
- Use event-handler code-behind or a Storyboard in Actions to express the on/off transition manually.
Example fix
<!-- before -->
<EventTrigger RoutedEvent="Mouse.MouseEnter">
<EventTrigger.EnterActions>
<BeginStoryboard>...</BeginStoryboard>
</EventTrigger.EnterActions>
</EventTrigger>
<!-- after -->
<EventTrigger RoutedEvent="Mouse.MouseEnter">
<BeginStoryboard>...</BeginStoryboard>
</EventTrigger> Defensive patterns
Strategy: validation
Validate before calling
if (eventTrigger.HasEnterActions || eventTrigger.HasExitActions)
throw new InvalidOperationException("EventTrigger does not support EnterActions/ExitActions."); Try / catch
try { trigger.Seal(); }
catch (InvalidOperationException) { /* move actions into Actions collection or a property Trigger */ } Prevention
- Use EnterActions/ExitActions only on Trigger/MultiTrigger, not EventTrigger.
- Put event-response actions in EventTrigger.Actions.
- Lint trigger XAML when copy-pasting between trigger types.
When it happens
Trigger: Assigning EventTrigger.EnterActions or EventTrigger.ExitActions (in XAML or code) and then sealing the trigger during style/template application.
Common situations: XAML written for a property Trigger pasted into an EventTrigger; assuming EventTrigger supports enter/exit semantics; code generators or converters emitting EnterActions for all trigger types.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- SR.EventTriggerDoNotSetProperties
- Animation_NoTextChildren
- Animation_NoTextChildren
- SR.Animation_NoTextChildren
- SR.Animation_NoTextChildren
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/62dc20d9f3199f49.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/EventTrigger.cs:219
public bool ShouldSerializeActions()
{
return ( _actions != null && _actions.Count > 0 );
}
///////////////////////////////////////////////////////////////////////
// Internal members
internal sealed override void Seal()
{
if( PropertyValues.Count > 0 )
{
throw new InvalidOperationException(SR.EventTriggerDoNotSetProperties);
}
// EnterActions/ExitActions aren't meaningful on event triggers.
if( HasEnterActions || HasExitActions )
{
throw new InvalidOperationException(SR.EventTriggerDoesNotEnterExit);
}
if (_routedEvent != null && _actions != null && _actions.Count > 0)
{
_actions.Seal(this); // TriggerActions need a link back to me to fetch the childId corresponding the sourceId string.
}
base.Seal(); // Should be almost a no-op given lack of PropertyValues
}
///////////////////////////////////////////////////////////////////////
// Private members
// Event that will fire this trigger
private RoutedEvent _routedEvent = null;
// Name of the Style.VisualTree node whose event to listen to.
// May remain the default value of null, which means the object being View on GitHub (pinned to 81131a70a4)