protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.AddComment); // Retrieve navigation parameter and set as current "DataContext" Vm = GlobalNavigation.GetAndRemoveParameter <FlowerViewModel>(Intent); // Avoid aggressive linker problem which removes the TextChanged event CommentText.TextChanged += (s, e) => { }; _saveBinding = this.SetBinding( () => CommentText.Text); // Avoid aggressive linker problem which removes the Click event SaveCommentButton.Click += (s, e) => { }; SaveCommentButton.SetCommand( "Click", Vm.SaveCommentCommand, _saveBinding); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Details); // Retrieve navigation parameter and set as current "DataContext" Vm = GlobalNavigation.GetAndRemoveParameter <FlowerViewModel>(Intent); var headerView = LayoutInflater.Inflate(Resource.Layout.CommentsListHeaderView, null); headerView.FindViewById <TextView>(Resource.Id.NameText).Text = Vm.Model.Name; headerView.FindViewById <TextView>(Resource.Id.DescriptionText).Text = Vm.Model.Description; CommentsList.AddHeaderView(headerView); CommentsList.Adapter = Vm.Model.Comments.GetAdapter(GetCommentTemplate); ImageDownloader.AssignImageAsync(FlowerImageView, Vm.Model.Image, this); AddCommentButton.SetCommand(Vm.AddCommentCommand); // Subscribing to events to avoid linker issues in release mode --------------------------------- // This "fools" the linker into believing that the events are used. // In fact we don't even subscribe to them. // See https://developer.xamarin.com/guides/android/advanced_topics/linking/ if (_falseFlag) { AddCommentButton.Click += (s, e) => { }; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.AddComment); // Retrieve navigation parameter and set as current "DataContext" Vm = GlobalNavigation.GetAndRemoveParameter <FlowerViewModel>(Intent); _saveBinding = this.SetBinding(() => CommentText.Text); SaveCommentButton.SetCommand( Vm.SaveCommentCommand, _saveBinding); // Subscribing to events to avoid linker issues in release mode --------------------------------- // This "fools" the linker into believing that the events are used. // In fact we don't even subscribe to them. // See https://developer.xamarin.com/guides/android/advanced_topics/linking/ if (_falseFlag) { SaveCommentButton.Click += (s, e) => { }; CommentText.TextChanged += (s, e) => { }; } }
private void BindFlowerCell(UITableViewCell cell, FlowerViewModel flower, NSIndexPath path) { cell.TextLabel.Text = flower.Model.Name; cell.ImageView.SetImage( new NSUrl(flower.ImageUri.AbsoluteUri), UIImage.FromBundle("flower_256_magenta.png")); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Details); // Retrieve navigation parameter and set as current "DataContext" Vm = GlobalNavigation.GetAndRemoveParameter <FlowerViewModel>(Intent); var headerView = LayoutInflater.Inflate(Resource.Layout.CommentsListHeaderView, null); headerView.FindViewById <TextView>(Resource.Id.NameText).Text = Vm.Model.Name; headerView.FindViewById <TextView>(Resource.Id.DescriptionText).Text = Vm.Model.Description; CommentsList.AddHeaderView(headerView); CommentsList.Adapter = Vm.Model.Comments.GetAdapter(GetCommentTemplate); ImageDownloader.AssignImageAsync(FlowerImageView, Vm.Model.Image, this); // Avoid aggressive linker problem which removes the Click event AddCommentButton.Click += (s, e) => { }; AddCommentButton.SetCommand( "Click", Vm.AddCommentCommand); }
public override void ViewDidLoad() { if (NavigationParameter == null) { throw new InvalidOperationException("No parameter found after navigation"); } Vm = (FlowerViewModel)NavigationParameter; DescriptionText = new UILabel(new CGRect(0, 0, 300, 235)) { LineBreakMode = UILineBreakMode.WordWrap, Lines = 0, }; Scroll.Add(DescriptionText); FlowerImage.SetImage( new NSUrl(Vm.ImageUri.AbsoluteUri), UIImage.FromBundle("flower_256_magenta.png")); this.SetBinding( () => Vm.Model.Name) .WhenSourceChanges( () => { // iOS is quite primitive and requires layout recalculation when the content // of UI elements changes. This is a good place to do that. NameText.Text = Vm.Model.Name; NameText.SizeToFit(); NameText.Frame = new CGRect(140, 75, 170, NameText.Bounds.Height); }); this.SetBinding( () => Vm.Model.Description) .WhenSourceChanges( () => { DescriptionText.Text = Vm.Model.Description; DescriptionText.SizeToFit(); DescriptionText.Frame = new CGRect( 0, 0, Scroll.Bounds.Width - 20, DescriptionText.Bounds.Height); Scroll.ContentSize = new CGSize(Scroll.Bounds.Width - 20, DescriptionText.Bounds.Height + 20); Scroll.SetNeedsLayout(); }); SeeCommentsButton.TouchUpInside += (s, e) => { var nav = ServiceLocator.Current.GetInstance <INavigationService>(); nav.NavigateTo(AppDelegate.SeeCommentsPageKey, Vm); }; base.ViewDidLoad(); }
public ActionResult Create(FlowerViewModel model) { if (ModelState.IsValid) { _flowerService.CreateFlower(User.Identity.GetUserId(), model.FlowerName); return(RedirectToAction("GetCurrentUser", "User")); } return(View(model)); }
public DetailsPage(FlowerViewModel flower) { InitializeComponent(); BindingContext = flower; ShowCommentsButton.Clicked += (s, e) => { var nav = ServiceLocator.Current.GetInstance <INavigationService>(); nav.NavigateTo(App.ShowCommentsPageKey, BindingContext); }; }
private void BindViewHolder(CachingViewHolder holder, FlowerViewModel flower, int position) { var image = holder.FindCachedViewById <ImageView>(Resource.Id.FlowerImageView); ImageDownloader.AssignImageAsync(image, flower.Model.Image, this); var title = holder.FindCachedViewById <TextView>(Resource.Id.NameTextView); title.Text = flower.Model.Name; var desc = holder.FindCachedViewById <TextView>(Resource.Id.DescriptionTextView); desc.Text = flower.Model.Description; }
public override void ViewDidLoad() { Vm = (FlowerViewModel)Nav.GetAndRemoveParameter(this); SaveCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Save, null); NavigationItem.SetRightBarButtonItem(SaveCommentButton, false); _commentBinding = this.SetBinding(() => CommentText.Text); SaveCommentButton.SetCommand( Vm.SaveCommentCommand, _commentBinding); base.ViewDidLoad(); }
public override void ViewDidLoad() { Vm = (FlowerViewModel)Nav.GetAndRemoveParameter(this); _tableController = Vm.Model.Comments.GetController( CreateCommentCell, BindCommentCell); _tableController.TableView = CommentsTableView; AddCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, null); NavigationItem.SetRightBarButtonItem(AddCommentButton, false); AddCommentButton.SetCommand(Vm.AddCommentCommand); base.ViewDidLoad(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.AddComment); // Retrieve navigation parameter and set as current "DataContext" Vm = GlobalNavigation.GetAndRemoveParameter <FlowerViewModel>(Intent); _saveBinding = this.SetBinding( () => CommentText.Text); SaveCommentButton.SetCommand( "Click", Vm.SaveCommentCommand, _saveBinding); }
private View GetFlowerAdapter(int position, FlowerViewModel flower, View convertView) { // Not reusing views here convertView = LayoutInflater.Inflate(Resource.Layout.FlowerTemplate, null); var title = convertView.FindViewById <TextView>(Resource.Id.NameTextView); title.Text = flower.Model.Name; var desc = convertView.FindViewById <TextView>(Resource.Id.DescriptionTextView); desc.Text = flower.Model.Description; var image = convertView.FindViewById <ImageView>(Resource.Id.FlowerImageView); ImageDownloader.AssignImageAsync(image, flower.Model.Image, this); return(convertView); }
public override void ViewDidLoad() { if (NavigationParameter == null) { throw new InvalidOperationException("No parameter found after navigation"); } Vm = (FlowerViewModel)NavigationParameter; _tableController = Vm.Model.Comments.GetController( CreateCommentCell, BindCommentCell); _tableController.TableView = CommentsTableView; AddCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, null); NavigationItem.SetRightBarButtonItem(AddCommentButton, false); AddCommentButton.SetCommand("Clicked", Vm.AddCommentCommand); base.ViewDidLoad(); }
public override void ViewDidLoad() { if (NavigationParameter == null) { throw new InvalidOperationException("No parameter found after navigation"); } Vm = (FlowerViewModel)NavigationParameter; SaveCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Save, null); NavigationItem.SetRightBarButtonItem(SaveCommentButton, false); _commentBinding = this.SetBinding( () => CommentText.Text) .UpdateSourceTrigger("Changed"); SaveCommentButton.SetCommand( "Clicked", Vm.SaveCommentCommand, _commentBinding); base.ViewDidLoad(); }
public AddCommentPage(FlowerViewModel flower) { InitializeComponent(); BindingContext = flower; }
public AddCommentViewController(FlowerViewModel flower) { Vm = flower; }
public DetailsViewController(FlowerViewModel flower) { Vm = flower; }