{"action":"opened","issue":{"url":"https://api.github.com/repos/MyToolkit/MyToolkit/issues/44","labels_url":"https://api.github.com/repos/MyToolkit/MyToolkit/issues/44/labels{/name}","comments_url":"https://api.github.com/repos/MyToolkit/MyToolkit/issues/44/comments","events_url":"https://api.github.com/repos/MyToolkit/MyToolkit/issues/44/events","html_url":"https://github.com/MyToolkit/MyToolkit/issues/44","id":128441663,"number":44,"title":"Issues with XamlBehaviors and implemented system events","user":{"login":"bigtlb","id":7816663,"avatar_url":"https://avatars.githubusercontent.com/u/7816663?v=3","gravatar_id":"","url":"https://api.github.com/users/bigtlb","html_url":"https://github.com/bigtlb","followers_url":"https://api.github.com/users/bigtlb/followers","following_url":"https://api.github.com/users/bigtlb/following{/other_user}","gists_url":"https://api.github.com/users/bigtlb/gists{/gist_id}","starred_url":"https://api.github.com/users/bigtlb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigtlb/subscriptions","organizations_url":"https://api.github.com/users/bigtlb/orgs","repos_url":"https://api.github.com/users/bigtlb/repos","events_url":"https://api.github.com/users/bigtlb/events{/privacy}","received_events_url":"https://api.github.com/users/bigtlb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-25T01:33:02Z","updated_at":"2016-01-25T01:33:02Z","closed_at":null,"body":"I have opened an [issue over with the XamlBehaviors team][1] about this as well.  I don't know who should be responsible.  But, I wanted to make you were aware as well.\r\n\r\nThe new XamlBehaviors have some custom logic in the EventTriggerBehavior for Windows Runtime (UWP) apps.  If the event handler delegate is defined in an assembly from the Windows Runtime, they assume the even will be handled in the runtime as well and will require marshalling.\r\n\r\n#### XamlBehavior EventTriggerBehavior.cs Code\r\n``` csharp\r\nthis.isWindowsRuntimeEvent = EventTriggerBehavior.IsWindowsRuntimeType(info.EventHandlerType);\r\nif (this.isWindowsRuntimeEvent)\r\n{\r\n    this.addEventHandlerMethod = add => (EventRegistrationToken)info.AddMethod.Invoke(this.resolvedSource, new object[] { add });\r\n    this.removeEventHandlerMethod = token => info.RemoveMethod.Invoke(this.resolvedSource, new object[] { token });\r\n\r\n    WindowsRuntimeMarshal.AddEventHandler(this.addEventHandlerMethod, this.removeEventHandlerMethod, this.eventHandler);\r\n}\r\nelse\r\n{\r\n    info.AddEventHandler(this.resolvedSource, this.eventHandler);\r\n}\r\n```\r\n\r\nThis causes issues in the DataGrid which is reusing the SelectionChangedEventHandler delegate definition.\r\n\r\nI was able to work around it easily in my application by copying and pasting the delegate definition into a copy of your source code.  But, I  am not sure if that is the most elegant solution, or how many other instances like that exist.\r\n\r\n``` csharp\r\n    /// <summary>A data grid control. </summary>\r\n    public class DataGrid : Control\r\n    {\r\n        private Grid _titleRowControl;\r\n        private MtListBox _listControl;\r\n        private bool _initialized = false;\r\n        private object _initialSelectedItem;\r\n        private object _initialFilter;\r\n\r\n        public delegate void SelectionChangedEventHandler(System.Object sender, SelectionChangedEventArgs e);\r\n```\r\n\r\n[1]: https://github.com/Microsoft/XamlBehaviors/issues/76"}}