예제 #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AppDelegate app = UIApplication.SharedApplication.Delegate as AppDelegate;

            //this.NavigationItem.TitleView = CreateNavTitle (PostViewModel.Post.FirstCategoryName);

            this.NavigationController.NavigationBarHidden = false;

            this.NavigationItem.SetLeftBarButtonItem(
                new UIBarButtonItem(UIImage.FromBundle("back")
                                    , UIBarButtonItemStyle.Plain
                                    , (sender, args) => {
                this.NavigationController.NavigationBarHidden = true;
                PostViewModel.BackCommand.Execute(null);
            }), true);



            this.webViewPost.ScrollView.Delegate = this;
//			this.NavigationItem.SetRightBarButtonItem(
//				new UIBarButtonItem(UIImage.FromBundle("comment")
//					, UIBarButtonItemStyle.Plain
//					, (sender, args) => {
//						PostViewModel.ShowCommentCommand.Execute(null);
//
//					}), true);
//
//			this.NavigationItem.SetRightBarButtonItem(
//				new UIBarButtonItem(UIImage.FromBundle("comment")
//					, UIBarButtonItemStyle.Plain
//					, (sender, args) => {
//						PostViewModel.ShowCommentCommand.Execute(null);
//
//					}), true);

            // Perform any additional setup after loading the view, typically from a nib.
            this.CreateBindingSet <PostView, PostViewModel>().Bind(this).For(v => v.IsLikedThisPost).To(vm => vm.IsLikedThisPost).Apply();

            this.CreateBindingSet <PostView, PostViewModel>().Bind(this).For(v => v.Html).To(vm => vm.Html).Apply();
            this.CreateBinding(lbLikeCount).For("Text").To <PostViewModel> (vm => vm.Like_count).Apply();
            this.CreateBinding(lbCommentCount).For("Text").To <PostViewModel> (vm => vm.Comment_count).Apply();

            this.CreateBinding(btnCommentBottom).For("TouchUpInside").To <PostViewModel> (vm => vm.ShowCommentCommand).Apply();
            this.CreateBinding(lbCommentCount).For("Tap").To <PostViewModel> (vm => vm.ShowCommentCommand).Apply();
            this.CreateBinding(lbCommentBotom).For("Tap").To <PostViewModel> (vm => vm.ShowCommentCommand).Apply();

            this.CreateBinding(btnLike).For("TouchUpInside").To <PostViewModel> (vm => vm.LikeCommand).Apply();
            this.CreateBinding(btnUnlike).For("TouchUpInside").To <PostViewModel> (vm => vm.UnLikeCommand).Apply();

            this.CreateBinding(pgrLoading).For("Hidden").To <PostViewModel> (vm => vm.IsLoading).WithConversion("Visibility").Apply();
            this.CreateBinding(btnLike).For("Hidden").To <PostViewModel> (vm => vm.IsUnLikedThisPost).WithConversion("Visibility").Apply();
            this.CreateBinding(btnUnlike).For("Hidden").To <PostViewModel> (vm => vm.IsLikedThisPost).WithConversion("Visibility").Apply();


            webViewPost.ShouldStartLoad = (w, urlRequest, navigationType) => {
                if (navigationType == UIWebViewNavigationType.LinkClicked)
                {
                    UIApplication.SharedApplication.OpenUrl(urlRequest.Url);
                    return(false);
                }
                return(true);
            };
            //webViewPost.LoadHtmlString ();
            PostViewModel.LoadPost();

            Relayout();
        }