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); // Avoid aggressive linker problem which removes the Click event AddCommentButton.Click += (s, e) => { }; AddCommentButton.SetCommand( "Click", Vm.AddCommentCommand); }
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) => { }; } }
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); }
protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); DataContext = GlobalNavigation.GetAndRemoveParameter(NavigationContext); }