{"action":"created","issue":{"url":"https://api.github.com/repos/MvvmCross/MvvmCross/issues/902","labels_url":"https://api.github.com/repos/MvvmCross/MvvmCross/issues/902/labels{/name}","comments_url":"https://api.github.com/repos/MvvmCross/MvvmCross/issues/902/comments","events_url":"https://api.github.com/repos/MvvmCross/MvvmCross/issues/902/events","html_url":"https://github.com/MvvmCross/MvvmCross/issues/902","id":56252196,"number":902,"title":"Unified API: binding target is garbage collected","user":{"login":"alxbog","id":1042383,"avatar_url":"https://avatars.githubusercontent.com/u/1042383?v=3","gravatar_id":"","url":"https://api.github.com/users/alxbog","html_url":"https://github.com/alxbog","followers_url":"https://api.github.com/users/alxbog/followers","following_url":"https://api.github.com/users/alxbog/following{/other_user}","gists_url":"https://api.github.com/users/alxbog/gists{/gist_id}","starred_url":"https://api.github.com/users/alxbog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alxbog/subscriptions","organizations_url":"https://api.github.com/users/alxbog/orgs","repos_url":"https://api.github.com/users/alxbog/repos","events_url":"https://api.github.com/users/alxbog/events{/privacy}","received_events_url":"https://api.github.com/users/alxbog/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":27,"created_at":"2015-02-02T15:44:58Z","updated_at":"2015-02-22T19:19:10Z","closed_at":null,"body":"Here is a sample ViewModel:\r\n```\r\npublic class FirstViewModel : MvxViewModel\r\n{\r\n    public async void Init()\r\n    {\r\n        while (true)\r\n        {\r\n            await Task.Delay(2000);\r\n            Hidden = !Hidden;\r\n        }\r\n    }\r\n\r\n    private bool _hidden;\r\n\r\n    public bool Hidden\r\n    {\r\n        get { return _hidden; }\r\n        set\r\n        {\r\n            _hidden = value;\r\n            RaisePropertyChanged(() => Hidden);\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nAnd corresponding View:\r\n```\r\npublic class FirstView : MvxViewController\r\n{\r\n    public override void ViewDidLoad()\r\n    {\r\n        base.ViewDidLoad();\r\n\r\n        var testView = new UIView(View.Bounds) { BackgroundColor = UIColor.Red };\r\n        Add(testView);\r\n\r\n        var set = this.CreateBindingSet<FirstView, FirstViewModel>();\r\n        set.Bind(testView).For(v => v.Hidden).To(vm => vm.Hidden);\r\n        set.Apply();\r\n    }\r\n\r\n    public override void ViewDidAppear(bool animated)\r\n    {\r\n        base.ViewDidAppear(animated);\r\n        GC.Collect();\r\n    }\r\n}\r\n```\r\n\r\nThe problem here is that Hidden binding doesn't work. Each time Hidden property of ViewModel is set the MVVMCross emits this error:\r\n> Weak Target is null in MvxUIViewHiddenTargetBinding - skipping set\r\n\r\nThis behaviour appears in Unified API projects because of using [new reference counting](http://developer.xamarin.com/guides/ios/advanced_topics/newrefcount/) of Xamarin.iOS. You can read more details on why *testView* gets garbage collected in [this question](http://stackoverflow.com/questions/28263138/migrating-to-unified-api-and-new-reference-counting) on SO.\r\n\r\nI suppose MVVMCross uses weak references for serving bindings.\r\n\r\nAnyway, can this problem be solved in a right way on the side of MVVMCross?"},"comment":{"url":"https://api.github.com/repos/MvvmCross/MvvmCross/issues/comments/75452143","html_url":"https://github.com/MvvmCross/MvvmCross/issues/902#issuecomment-75452143","issue_url":"https://api.github.com/repos/MvvmCross/MvvmCross/issues/902","id":75452143,"user":{"login":"slodge","id":533662,"avatar_url":"https://avatars.githubusercontent.com/u/533662?v=3","gravatar_id":"","url":"https://api.github.com/users/slodge","html_url":"https://github.com/slodge","followers_url":"https://api.github.com/users/slodge/followers","following_url":"https://api.github.com/users/slodge/following{/other_user}","gists_url":"https://api.github.com/users/slodge/gists{/gist_id}","starred_url":"https://api.github.com/users/slodge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slodge/subscriptions","organizations_url":"https://api.github.com/users/slodge/orgs","repos_url":"https://api.github.com/users/slodge/repos","events_url":"https://api.github.com/users/slodge/events{/privacy}","received_events_url":"https://api.github.com/users/slodge/received_events","type":"User","site_admin":false},"created_at":"2015-02-22T19:19:10Z","updated_at":"2015-02-22T19:19:10Z","body":"Has 3.5.1-alpha1 helped with this?\r\n\r\nKeen to push alpha2 soon - but interested in feedback first :)"}}