{"action":"created","issue":{"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/572","repository_url":"https://api.github.com/repos/xamarin/Xamarin.Forms","labels_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/572/labels{/name}","comments_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/572/comments","events_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/572/events","html_url":"https://github.com/xamarin/Xamarin.Forms/pull/572","id":192191026,"number":572,"title":"Allow Command CanExecute to recover when run on inherited bindingcontext","user":{"login":"hartez","id":538025,"avatar_url":"https://avatars.githubusercontent.com/u/538025?v=3","gravatar_id":"","url":"https://api.github.com/users/hartez","html_url":"https://github.com/hartez","followers_url":"https://api.github.com/users/hartez/followers","following_url":"https://api.github.com/users/hartez/following{/other_user}","gists_url":"https://api.github.com/users/hartez/gists{/gist_id}","starred_url":"https://api.github.com/users/hartez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hartez/subscriptions","organizations_url":"https://api.github.com/users/hartez/orgs","repos_url":"https://api.github.com/users/hartez/repos","events_url":"https://api.github.com/users/hartez/events{/privacy}","received_events_url":"https://api.github.com/users/hartez/received_events","type":"User","site_admin":false},"labels":[{"id":370047471,"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/labels/cla-already-signed","name":"cla-already-signed","color":"009800","default":false},{"id":370047468,"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/labels/cla-not-required","name":"cla-not-required","color":"009800","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-29T05:25:07Z","updated_at":"2016-11-29T12:12:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/pulls/572","html_url":"https://github.com/xamarin/Xamarin.Forms/pull/572","diff_url":"https://github.com/xamarin/Xamarin.Forms/pull/572.diff","patch_url":"https://github.com/xamarin/Xamarin.Forms/pull/572.patch"},"body":"### Description of Change ###\r\n\r\nOn WinRT/UWP during the process of binding, items in a `ListView` initially inherit the binding context of the `ListView` before getting a more specific binding context. If the `DataTemplate` of the `ListView` includes an item which has both \r\n\r\n- a bound `Command` which includes a `CanExecute` method and\r\n- a bound `CommandParameter`\r\n\r\nthe initial binding of the item will trigger a check on the `CanExecute` method (to determine if `IsEnabled` should be true). The `CanExecute` method attempts to cast the binding context to the correct type and throws an `InvalidCastException`. The `InvalidCastException` is not fatal, but it causes the rest of the `DataTemplate` binding to fail, and the `ListView` items will appear blank (though in the most recent version of XF they are still tappable). \r\n\r\nThis change checks the type before executing the command and does not execute the command if the type is incorrect; it also checks the type before checking `CanExecute` and returns `false` if the type is incorrect.\r\n\r\n### Bugs Fixed ###\r\n\r\n- [47971 – XF UWP ListView Items no longer display ImageCell is the problem](https://bugzilla.xamarin.com/show_bug.cgi?id=47971)\r\n\r\n### API Changes ###\r\n\r\nList all API changes here (or just put None), example:\r\n\r\nNone\r\n\r\n### Behavioral Changes ###\r\n\r\nNone\r\n\r\n### PR Checklist ###\r\n\r\n- [x] Has tests (if omitted, state reason in description)\r\n- [x] Rebased on top of master at time of PR\r\n- [x] Changes adhere to coding standard\r\n- [x] Consolidate commits as makes sense\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/comments/263554768","html_url":"https://github.com/xamarin/Xamarin.Forms/pull/572#issuecomment-263554768","issue_url":"https://api.github.com/repos/xamarin/Xamarin.Forms/issues/572","id":263554768,"user":{"login":"hartez","id":538025,"avatar_url":"https://avatars.githubusercontent.com/u/538025?v=3","gravatar_id":"","url":"https://api.github.com/users/hartez","html_url":"https://github.com/hartez","followers_url":"https://api.github.com/users/hartez/followers","following_url":"https://api.github.com/users/hartez/following{/other_user}","gists_url":"https://api.github.com/users/hartez/gists{/gist_id}","starred_url":"https://api.github.com/users/hartez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hartez/subscriptions","organizations_url":"https://api.github.com/users/hartez/orgs","repos_url":"https://api.github.com/users/hartez/repos","events_url":"https://api.github.com/users/hartez/events{/privacy}","received_events_url":"https://api.github.com/users/hartez/received_events","type":"User","site_admin":false},"created_at":"2016-11-29T12:12:51Z","updated_at":"2016-11-29T12:12:51Z","body":"Taking the suggestion from @StephaneDelcroix and just avoiding the `InvalidCastException` in the first place."}}
{"actor":{"display_login":"hartez"}}