{"record":{"id":"62dc20d9f3199f49","repo":"dotnet/wpf","slug":"sr-eventtriggerdoesnotenterexit","errorCode":null,"errorMessage":"SR.EventTriggerDoesNotEnterExit","messagePattern":"SR\\.EventTriggerDoesNotEnterExit","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/EventTrigger.cs","lineNumber":219,"sourceCode":"        public bool ShouldSerializeActions()\n        {\n            return ( _actions != null && _actions.Count > 0 );\n        }\n\n        ///////////////////////////////////////////////////////////////////////\n        // Internal members\n        \n        internal sealed override void Seal()\n        {\n            if( PropertyValues.Count > 0 )\n            {\n                throw new InvalidOperationException(SR.EventTriggerDoNotSetProperties);\n            }\n\n            // EnterActions/ExitActions aren't meaningful on event triggers.\n            if( HasEnterActions || HasExitActions )\n            {\n                throw new InvalidOperationException(SR.EventTriggerDoesNotEnterExit);\n            }\n\n            if (_routedEvent != null && _actions != null && _actions.Count > 0)\n            {\n                _actions.Seal(this);  // TriggerActions need a link back to me to fetch the childId corresponding the sourceId string.\n            }\n\n            base.Seal(); // Should be almost a no-op given lack of PropertyValues\n        }\n\n        ///////////////////////////////////////////////////////////////////////\n        // Private members\n\n        // Event that will fire this trigger\n        private RoutedEvent _routedEvent = null;\n\n        // Name of the Style.VisualTree node whose event to listen to.\n        //  May remain the default value of null, which  means the object being ","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/EventTrigger.cs#L201-L237","documentation":"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.","triggerScenarios":"Assigning EventTrigger.EnterActions or EventTrigger.ExitActions (in XAML or code) and then sealing the trigger during style/template application.","commonSituations":"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.","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."],"exampleFix":"<!-- before -->\n<EventTrigger RoutedEvent=\"Mouse.MouseEnter\">\n  <EventTrigger.EnterActions>\n    <BeginStoryboard>...</BeginStoryboard>\n  </EventTrigger.EnterActions>\n</EventTrigger>\n\n<!-- after -->\n<EventTrigger RoutedEvent=\"Mouse.MouseEnter\">\n  <BeginStoryboard>...</BeginStoryboard>\n</EventTrigger>","handlingStrategy":"validation","validationCode":"if (eventTrigger.HasEnterActions || eventTrigger.HasExitActions)\n    throw new InvalidOperationException(\"EventTrigger does not support EnterActions/ExitActions.\");","typeGuard":null,"tryCatchPattern":"try { trigger.Seal(); }\ncatch (InvalidOperationException) { /* move actions into Actions collection or a property Trigger */ }","preventionTips":["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."],"tags":["wpf","xaml","unsupported-operation","eventtrigger"],"backgroundTag":"unsupported-operation","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}