Merge pull request #77 from PedroLamas/eventtriggerbehaviorruntime

Fixed #76: Properly check for Windows Runtime events in EventTriggerBehavior
This commit is contained in:
Scott Lovegrove 2016-01-27 09:27:39 +00:00
Родитель 4e18bade6c 71bf9ba628
Коммит 393920f7d6
1 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -185,7 +185,7 @@ namespace Microsoft.Xaml.Interactions.Core
MethodInfo methodInfo = typeof(EventTriggerBehavior).GetTypeInfo().GetDeclaredMethod("OnEvent");
this.eventHandler = methodInfo.CreateDelegate(info.EventHandlerType, this);
this.isWindowsRuntimeEvent = EventTriggerBehavior.IsWindowsRuntimeType(info.EventHandlerType);
this.isWindowsRuntimeEvent = EventTriggerBehavior.IsWindowsRuntimeEvent(info);
if (this.isWindowsRuntimeEvent)
{
this.addEventHandlerMethod = add => (EventRegistrationToken)info.AddMethod.Invoke(this.resolvedSource, new object[] { add });
@ -288,6 +288,13 @@ namespace Microsoft.Xaml.Interactions.Core
return (parent != null || (rootVisual != null && element == rootVisual));
}
private static bool IsWindowsRuntimeEvent(EventInfo eventInfo)
{
return eventInfo != null &&
EventTriggerBehavior.IsWindowsRuntimeType(eventInfo.EventHandlerType) &&
EventTriggerBehavior.IsWindowsRuntimeType(eventInfo.DeclaringType);
}
private static bool IsWindowsRuntimeType(Type type)
{
if (type != null)