public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. if (PostCommentsViewModel == null) return; RegisterForKeyboardNotifications (); this.NavigationItem.TitleView = CreateNavTitle ("Comments"); this.NavigationItem.SetLeftBarButtonItem( new UIBarButtonItem(UIImage.FromBundle("back") , UIBarButtonItemStyle.Plain , (sender, args) => { this.NavigationController.NavigationBarHidden = true; PostCommentsViewModel.BackCommand.Execute(null); }), true); this.NavigationItem.SetRightBarButtonItem( new UIBarButtonItem(UIImage.FromBundle("refresh") , UIBarButtonItemStyle.Plain , (sender, args) => { PostCommentsViewModel.RefreshCommentsCommand.Execute(null); }), true); // this.CreateBindingSet<PostCommentsView, PostCommentsViewModel> ().Bind (this).For (v => v.CommentText).To (vm => vm.CommentText).Apply (); var TableSourceComments = new TableSourceComments (tableComments); this.CreateBinding (TableSourceComments).To<PostCommentsViewModel> (vm => vm.Comments).Apply (); tableComments.Source = TableSourceComments; tableComments.ReloadData (); this.CreateBinding (viewNoComment).For ("Hidden").To<PostCommentsViewModel> (vm => vm.IsNoComment).WithConversion ("Visibility").Apply (); this.CreateBinding (tableComments).For ("Hidden").To<PostCommentsViewModel> (vm => vm.HasComment).WithConversion ("Visibility").Apply (); this.CreateBinding (prgLoading).For ("Hidden").To<PostCommentsViewModel> (vm => vm.IsLoading).WithConversion ("Visibility").Apply (); this.CreateBinding(lbPostTitle).For("Text").To<PostCommentsViewModel> (vm => vm.NewsTitle).Apply(); this.CreateBinding (txtComment).For ("Text").To<PostCommentsViewModel> (vm => vm.CommentText).Apply (); this.CreateBinding (txtName).For ("Text").To<PostCommentsViewModel> (vm => vm.CommentName).Apply (); this.CreateBinding (txtEmail).For ("Text").To<PostCommentsViewModel> (vm => vm.CommentEmail).Apply (); this.CreateBinding (btnPostComment).For ("TouchUpInside").To<PostCommentsViewModel> (vm => vm.PostCommentCommand).Apply (); isButtonActived = false; txtComment.EditingChanged += (sender, e) => { UITextField t = (UITextField)sender; if ( string.IsNullOrEmpty(t.Text)) { isButtonActived = false; btnPostComment.ImageView.Image = imgButtonInactive; } else if (!isButtonActived){ isButtonActived = true; btnPostComment.ImageView.Image = imgButtonActive; } }; txtComment.EditingDidBegin += (object sender, EventArgs e) => { viewTxtCommentDivider.BackgroundColor = COLOR_HIGHLIGHT; }; txtComment.EditingDidEnd += (object sender, EventArgs e) => { viewTxtCommentDivider.BackgroundColor = UIColor.LightGray; }; txtName.EditingDidBegin += (object sender, EventArgs e) => { viewTxtNameDivider.BackgroundColor = COLOR_HIGHLIGHT; }; txtName.EditingDidEnd += (object sender, EventArgs e) => { viewTxtNameDivider.BackgroundColor = UIColor.LightGray; }; txtEmail.EditingDidBegin += (object sender, EventArgs e) => { viewTxtEmailDivider.BackgroundColor = COLOR_HIGHLIGHT; }; txtEmail.EditingDidEnd += (object sender, EventArgs e) => { viewTxtEmailDivider.BackgroundColor = UIColor.LightGray; }; // txtComment.Delegate = this; this.PostCommentsViewModel.PostCommentPressed += (sender, e) => { View.EndEditing(true); if (!(e is ErrorEventArgs)) { } tableComments.ContentOffset = new CoreGraphics.CGPoint(0, nfloat.MaxValue);//scroll to bottom }; DismissKeyboardOnBackgroundTap (); Relayout (); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. if (PostCommentsViewModel == null) { return; } RegisterForKeyboardNotifications(); this.NavigationItem.TitleView = CreateNavTitle("Comments"); this.NavigationItem.SetLeftBarButtonItem( new UIBarButtonItem(UIImage.FromBundle("back") , UIBarButtonItemStyle.Plain , (sender, args) => { this.NavigationController.NavigationBarHidden = true; PostCommentsViewModel.BackCommand.Execute(null); }), true); this.NavigationItem.SetRightBarButtonItem( new UIBarButtonItem(UIImage.FromBundle("refresh") , UIBarButtonItemStyle.Plain , (sender, args) => { PostCommentsViewModel.RefreshCommentsCommand.Execute(null); }), true); // this.CreateBindingSet<PostCommentsView, PostCommentsViewModel> ().Bind (this).For (v => v.CommentText).To (vm => vm.CommentText).Apply (); var TableSourceComments = new TableSourceComments(tableComments); this.CreateBinding(TableSourceComments).To <PostCommentsViewModel> (vm => vm.Comments).Apply(); tableComments.Source = TableSourceComments; tableComments.ReloadData(); this.CreateBinding(viewNoComment).For("Hidden").To <PostCommentsViewModel> (vm => vm.IsNoComment).WithConversion("Visibility").Apply(); this.CreateBinding(tableComments).For("Hidden").To <PostCommentsViewModel> (vm => vm.HasComment).WithConversion("Visibility").Apply(); this.CreateBinding(prgLoading).For("Hidden").To <PostCommentsViewModel> (vm => vm.IsLoading).WithConversion("Visibility").Apply(); this.CreateBinding(lbPostTitle).For("Text").To <PostCommentsViewModel> (vm => vm.NewsTitle).Apply(); this.CreateBinding(txtComment).For("Text").To <PostCommentsViewModel> (vm => vm.CommentText).Apply(); this.CreateBinding(txtName).For("Text").To <PostCommentsViewModel> (vm => vm.CommentName).Apply(); this.CreateBinding(txtEmail).For("Text").To <PostCommentsViewModel> (vm => vm.CommentEmail).Apply(); this.CreateBinding(btnPostComment).For("TouchUpInside").To <PostCommentsViewModel> (vm => vm.PostCommentCommand).Apply(); isButtonActived = false; txtComment.EditingChanged += (sender, e) => { UITextField t = (UITextField)sender; if (string.IsNullOrEmpty(t.Text)) { isButtonActived = false; btnPostComment.ImageView.Image = imgButtonInactive; } else if (!isButtonActived) { isButtonActived = true; btnPostComment.ImageView.Image = imgButtonActive; } }; txtComment.EditingDidBegin += (object sender, EventArgs e) => { viewTxtCommentDivider.BackgroundColor = COLOR_HIGHLIGHT; }; txtComment.EditingDidEnd += (object sender, EventArgs e) => { viewTxtCommentDivider.BackgroundColor = UIColor.LightGray; }; txtName.EditingDidBegin += (object sender, EventArgs e) => { viewTxtNameDivider.BackgroundColor = COLOR_HIGHLIGHT; }; txtName.EditingDidEnd += (object sender, EventArgs e) => { viewTxtNameDivider.BackgroundColor = UIColor.LightGray; }; txtEmail.EditingDidBegin += (object sender, EventArgs e) => { viewTxtEmailDivider.BackgroundColor = COLOR_HIGHLIGHT; }; txtEmail.EditingDidEnd += (object sender, EventArgs e) => { viewTxtEmailDivider.BackgroundColor = UIColor.LightGray; }; // txtComment.Delegate = this; this.PostCommentsViewModel.PostCommentPressed += (sender, e) => { View.EndEditing(true); if (!(e is ErrorEventArgs)) { } tableComments.ContentOffset = new CoreGraphics.CGPoint(0, nfloat.MaxValue); //scroll to bottom }; DismissKeyboardOnBackgroundTap(); Relayout(); }