Пример #1
0
        protected override void OnCreate(Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            vm = new TaskViewModel();

            int taskID = Intent.GetIntExtra("TaskId", 0);

            if (taskID > 0)
            {
                currentTask = vm.Get(taskID);
            }
            else
            {
                currentTask = new Task();
            }


            SetContentView(Resource.Layout.TaskView);

            titleText    = FindViewById <EditText>(Resource.Id.TitleText);
            doneCheckBox = FindViewById <CheckBox>(Resource.Id.DoneCheckBox);

            titleText.Text       = currentTask.Title;
            doneCheckBox.Checked = currentTask.Done;

            saveButton = FindViewById <Button>(Resource.Id.SaveButton);

            saveButton.Click += (sender, e) => {
                currentTask.Title = titleText.Text;
                currentTask.Done  = doneCheckBox.Checked;

                currentTask.Id = vm.Save(currentTask);                  // unnecessary

                Finish();
            };


            var cancelButton = FindViewById <Button> (Resource.Id.CancelButton);

            cancelButton.Click += (sender, e) => {
                Finish();
            };
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			SaveButton.TouchUpInside += (sender, e) => {
				// retrieve data from UIneed 
				currentTask.Title = TitleText.Text;
				currentTask.Done = DoneSwitch.On;

				var vm = new TaskViewModel();
				currentTask.Id = vm.Save (currentTask); // unnecessary

				NavigationController.PopToRootViewController (true);
			};

			CancelButton.TouchUpInside += (sender, e) => {
				NavigationController.PopToRootViewController (true);
			};
		}
Пример #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            SaveButton.TouchUpInside += (sender, e) => {
                // retrieve data from UIneed
                currentTask.Title = TitleText.Text;
                currentTask.Done  = DoneSwitch.On;

                var vm = new TaskViewModel();
                currentTask.Id = vm.Save(currentTask);                  // unnecessary

                NavigationController.PopToRootViewController(true);
            };

            CancelButton.TouchUpInside += (sender, e) => {
                NavigationController.PopToRootViewController(true);
            };
        }
Пример #4
0
		protected override void OnCreate (Android.OS.Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);

			vm = new TaskViewModel ();

			int taskID = Intent.GetIntExtra("TaskId", 0);
			if (taskID > 0) {
				currentTask = vm.Get (taskID);
			} else {
				currentTask = new Task ();
			}


			SetContentView(Resource.Layout.TaskView);

			titleText = FindViewById<EditText>(Resource.Id.TitleText);
			doneCheckBox = FindViewById<CheckBox>(Resource.Id.DoneCheckBox);

			titleText.Text = currentTask.Title;
			doneCheckBox.Checked = currentTask.Done;

			saveButton = FindViewById<Button>(Resource.Id.SaveButton);

			saveButton.Click += (sender, e) => {
				currentTask.Title = titleText.Text;
				currentTask.Done = doneCheckBox.Checked;

				currentTask.Id = vm.Save (currentTask); // unnecessary

				Finish();
			};


			var cancelButton = FindViewById<Button> (Resource.Id.CancelButton);
			cancelButton.Click += (sender, e) => {
				Finish();
			};
		}