HandyOrg/HandyControl · error · ArgumentException
ExceptionStringTable.EventTriggerBaseInvalidEventExceptionMe…
Error message
ExceptionStringTable.EventTriggerBaseInvalidEventExceptionMessage
What it means
RegisterEvent finds the event but rejects it if IsValidEvent(eventInfo) fails — typically the event's handler signature is not compatible with the trigger's expected EventHandler/EventArgs shape. When a SourceObject is set, ArgumentException EventTriggerBaseInvalidEventExceptionMessage is thrown naming the event and the type.
Solutions
- Point EventName at an event with a compatible signature (object, EventArgs-derived) for the trigger type.
- Change the event's delegate type to EventHandler<TEventArgs> or the required signature.
- Use a custom EventTriggerBase subclass overriding IsValidEvent if you must support non-standard events.
- Attach the trigger to a different source object that exposes a standard event.
Example fix
// before public event MyCustomDelegate SomethingHappened; // invalid signature for EventTrigger // after public event EventHandler SomethingHappened;
Defensive patterns
Strategy: validation
Validate before calling
var evt = sourceObject?.GetType().GetEvent(eventName);
if (evt != null && !typeof(EventHandler).IsAssignableFrom(evt.EventHandlerType) &&
!(evt.EventHandlerType.IsGenericType && typeof(EventHandler<>).MakeGenericType(evt.EventHandlerType.GetGenericArguments()[0]).IsAssignableFrom(evt.EventHandlerType)))
Console.WriteLine($"Event '{eventName}' has an unsupported handler signature"); Type guard
static bool HasCompatibleSignature(EventInfo e) =>
e != null && typeof(Delegate).IsAssignableFrom(e.EventHandlerType) &&
e.EventHandlerType.GetMethod("Invoke").GetParameters().Length == 2; Try / catch
try { trigger.Attach(associatedObject); }
catch (ArgumentException ex) when (ex.Message.Contains("InvalidEvent")) {
// use a standard EventHandler-based event or override IsValidEvent
} Prevention
- Expose custom events with EventHandler/EventHandler<TEventArgs>.
- Only point EventTrigger at events with (object, EventArgs) signatures.
- For non-standard events, subclass EventTriggerBase and override IsValidEvent.
- Prefer routed events for WPF sources.
When it happens
Trigger: EventName resolves to an event whose signature does not pass IsValidEvent (e.g. a custom delegate not derived from EventHandler pattern expected by EventTriggerBase), raised from OnEventNameChanged or OnSourceChangedImpl.
Common situations: Pointing EventTrigger at a custom event with a non-standard delegate type; targeting routed events with mismatched EventArgs; using an event on a POCO whose delegate doesn't match the trigger's required handler signature.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- ExceptionStringTable.DefaultTriggerAttributeInvalidTriggerTy…
- ExceptionStringTable.EventTriggerCannotFindEventNameExceptio…
- ExceptionStringTable.DuplicateItemInCollectionExceptionMessa…
- ExceptionStringTable.CannotHostBehaviorMultipleTimesExceptio…
- ExceptionStringTable.TypeConstraintViolatedExceptionMessage
AI-assisted analysis of HandyOrg/HandyControl@2c0875ebd6 (2026-09-14).
Data as JSON: /api/errors/f53ed0c52362b2c6.
Report an issue: GitHub.
Appendix: source
Thrown at src/Shared/System.Windows.Interactivity/EventTriggerBase.cs:239
base2.UnregisterEvent(newSource, base2.GetEventName());
base2.OnSourceChanged(args.OldValue, args.NewValue);
}
}
private void RegisterEvent(object obj, string eventName)
{
var eventInfo = obj.GetType().GetEvent(eventName);
if (eventInfo == null)
{
if (SourceObject != null)
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
ExceptionStringTable.EventTriggerCannotFindEventNameExceptionMessage,
new object[] { eventName, obj.GetType().Name }));
}
else if (!IsValidEvent(eventInfo))
{
if (SourceObject != null)
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
ExceptionStringTable.EventTriggerBaseInvalidEventExceptionMessage,
new object[] { eventName, obj.GetType().Name }));
}
else
{
_eventHandlerMethodInfo =
typeof(EventTriggerBase).GetMethod("OnEventImpl", BindingFlags.NonPublic | BindingFlags.Instance);
eventInfo.AddEventHandler(obj,
Delegate.CreateDelegate(eventInfo.EventHandlerType, this, _eventHandlerMethodInfo ?? throw new InvalidOperationException()));
}
}
private void RegisterLoaded(FrameworkElement associatedElement)
{
if (!IsLoadedRegistered && associatedElement != null)
{
associatedElement.Loaded += OnEventImpl;
IsLoadedRegistered = true;View on GitHub (pinned to 2c0875ebd6)