{"record":{"id":"0fb560ab4a72bca5","repo":"HandyOrg/HandyControl","slug":"exceptionstringtable-0fb560","errorCode":null,"errorMessage":"ExceptionStringTable.EventTriggerCannotFindEventNameExceptionMessage","messagePattern":"ExceptionStringTable\\.EventTriggerCannotFindEventNameExceptionMessage","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Shared/System.Windows.Interactivity/EventTriggerBase.cs","lineNumber":232,"sourceCode":"        if (args.NewValue == null)\n        {\n            base2.OnSourceChanged(args.OldValue, newSource);\n        }\n        else\n        {\n            if (args.OldValue == null && newSource != null)\n                base2.UnregisterEvent(newSource, base2.GetEventName());\n            base2.OnSourceChanged(args.OldValue, args.NewValue);\n        }\n    }\n\n    private void RegisterEvent(object obj, string eventName)\n    {\n        var eventInfo = obj.GetType().GetEvent(eventName);\n        if (eventInfo == null)\n        {\n            if (SourceObject != null)\n                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,\n                    ExceptionStringTable.EventTriggerCannotFindEventNameExceptionMessage,\n                    new object[] { eventName, obj.GetType().Name }));\n        }\n        else if (!IsValidEvent(eventInfo))\n        {\n            if (SourceObject != null)\n                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,\n                    ExceptionStringTable.EventTriggerBaseInvalidEventExceptionMessage,\n                    new object[] { eventName, obj.GetType().Name }));\n        }\n        else\n        {\n            _eventHandlerMethodInfo =\n                typeof(EventTriggerBase).GetMethod(\"OnEventImpl\", BindingFlags.NonPublic | BindingFlags.Instance);\n            eventInfo.AddEventHandler(obj,\n                Delegate.CreateDelegate(eventInfo.EventHandlerType, this, _eventHandlerMethodInfo ?? throw new InvalidOperationException()));\n        }\n    }","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/src/Shared/System.Windows.Interactivity/EventTriggerBase.cs#L214-L250","documentation":"When an EventTriggerBase registers its handler, it looks up EventName via reflection on the source object's type. If the event does not exist and a SourceObject is set, ArgumentException EventTriggerCannotFindEventNameExceptionMessage is thrown with the event name and the type searched.","triggerScenarios":"Setting EventTrigger.EventName (via OnEventNameChanged) or changing the source (OnSourceChangedImpl) so RegisterEvent is called on an object whose type has no event with that name.","commonSituations":"Typo in EventName in XAML; renaming or removing an event in a control library update; pointing the trigger at a base/plain type (e.g. FrameworkElement) that lacks the event; case-sensitive mismatch in event name.","solutions":["Correct EventName to an event that exists on the source object's type (e.g. 'Click', 'MouseLeftButtonDown').","Verify the resolved SourceObject is the intended type that actually declares the event.","Check spelling/casing of EventName; it is case-sensitive via Type.GetEvent.","If the event was removed by a library upgrade, update to the new event name or add a compat shim."],"exampleFix":"<!-- before -->\n<i:EventTrigger EventName=\"Clicck\" SourceName=\"okButton\" />\n<!-- after -->\n<i:EventTrigger EventName=\"Click\" SourceName=\"okButton\" />","handlingStrategy":"validation","validationCode":"if (sourceObject?.GetType().GetEvent(eventName) == null)\n    Console.WriteLine($\"Event '{eventName}' does not exist on {sourceObject.GetType().Name}\");","typeGuard":"static bool EventExists(object source, string eventName) =>\n    source != null && source.GetType().GetEvent(eventName) != null;","tryCatchPattern":"try { trigger.Attach(associatedObject); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"CannotFindEventName\")) {\n    // correct EventName for this source type\n}","preventionTips":["Verify EventName exists on the source type (IntelliSense/reflector).","Watch for event renames/removals after library upgrades.","Remember GetEvent is case-sensitive.","Ensure SourceName resolves to the type that actually declares the event."],"tags":["wpf","interactivity","reflection","event-not-found","resource-not-found"],"backgroundTag":"resource-not-found","analyzedSha":"2c0875ebd67326e0c67282967e3e809c69282fee","analyzedAt":"2026-09-14T14:45:29.754Z","contentChangedAt":"2026-09-14T14:45:29.754Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}