async void DatePickerButtonTapped (object sender, EventArgs e)
        {
            var modalPicker = new ModalPickerViewController(ModalPickerType.Date, "Select A Date", this)
            {
                HeaderBackgroundColor = UIColor.Red,
                HeaderTextColor = UIColor.White,
                TransitioningDelegate = new ModalPickerTransitionDelegate(),
                ModalPresentationStyle = UIModalPresentationStyle.Custom
            };

            modalPicker.DatePicker.Mode = UIDatePickerMode.Date;

            modalPicker.OnModalPickerDismissed += (s, ea) => 
            {
                var dateFormatter = new NSDateFormatter()
                {
                    DateFormat = "MMMM dd, yyyy"
                };

                PickedLabel.Text = dateFormatter.ToString(modalPicker.DatePicker.Date);
            };

            await PresentViewControllerAsync(modalPicker, true);
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			newDate = new ProposedDate ();
			// Perform any additional setup after loading the view, typically from a nib.
			modalPicker = new ModalPickerViewController(ModalPickerType.Date, "2 hrs to 10 days", this) {
				HeaderBackgroundColor = UIColor.Red,
				HeaderTextColor = UIColor.White,
				TransitioningDelegate = new ModalPickerTransitionDelegate(),
				ModalPresentationStyle = UIModalPresentationStyle.Custom
			};

			modalPicker.DatePicker.Mode = UIDatePickerMode.DateAndTime;
			DateTime minDate = DateTime.UtcNow.AddHours (2);
			DateTime maxDate = DateTime.UtcNow.AddDays (10);

			modalPicker.DatePicker.MinimumDate = minDate.DateTimeToNSDate();
			modalPicker.DatePicker.MaximumDate = maxDate.DateTimeToNSDate();
			modalPicker.DatePicker.MinuteInterval = 15;
			modalPicker.OnModalPickerDismissed += HandleDatePicked;


			DateStartBtn.TouchUpInside += (object sender, EventArgs e) => 
			{
				ShowDateController();


			};

			CancelDateBtn.TouchUpInside += (object sender, EventArgs e) => {
				DismissViewController(true, null);
			};

			CreateDateBtn.TouchUpInside += (object sender, EventArgs e) => {
				LettuceServer.Instance.CreateDate(newDate, (theDate) =>
					{
						newDate = theDate;
						InvokeOnMainThread(() => {
						DismissViewController(true, null);
						if (DateCreated != null)
							DateCreated(theDate);
						});
					});

			};

			AddActivityBtn.TouchUpInside += (sender, e) => {
				if ((newDate.activities == null) || (newDate.activities.Count == 0))
					AddNewActivityToDate ();
				else
					RemoveAllActivitiesFromDate ();
			};
				

			ActivityTableView.RegisterNibForCellReuse (UINib.FromName (ActivitySummaryCell.Key, NSBundle.MainBundle), ActivitySummaryCell.Key);
			ActivityTableView.Source = new DateActivityDataSource (this.newDate);
			ActivityTableView.RowHeight = 164;

			keyWatcher = NSNotificationCenter.DefaultCenter.AddObserver (UITextView.TextDidChangeNotification, (notification) => {
				newDate.description = DescriptionText.Text;
				newDate.title = HeadlineText.Text;
				UpdateCreateButton();
			});
		}
        async void CustomPickerButtonTapped (object sender, EventArgs e)
        {
            //Create custom data source
            var customDatesList = new List<string>();
            foreach(var date in _customDates)
            {
                customDatesList.Add(date.ToString("ddd, MMM dd, yyyy"));
            }

            //Create the modal picker and style it as you see fit
            var modalPicker = new ModalPickerViewController(ModalPickerType.Custom, "Select A Date", this)
            {
                HeaderBackgroundColor = UIColor.Blue,
                HeaderTextColor = UIColor.White,
                TransitioningDelegate = new ModalPickerTransitionDelegate(),
                ModalPresentationStyle = UIModalPresentationStyle.Custom
            };

            //Create the model for the Picker View
            modalPicker.PickerView.Model = new CustomPickerModel(customDatesList);

            //On an item is selected, update our label with the selected item.
            modalPicker.OnModalPickerDismissed += (s, ea) => 
            {
                var index = modalPicker.PickerView.SelectedRowInComponent(0);
                PickedLabel.Text = customDatesList[(int)index];
            };

            await PresentViewControllerAsync(modalPicker, true);
        }
        bool OnTextFieldShouldBeginEditing(UITextField textField)
        {
            var modalPicker = new ModalPickerViewController(ModalPickerType.Date, "Select A Date", this)
            {
                HeaderBackgroundColor = UIColor.Red,
                HeaderTextColor = UIColor.White,
                TransitioningDelegate = new ModalPickerTransitionDelegate(),
                ModalPresentationStyle = UIModalPresentationStyle.Custom
            };

            modalPicker.DatePicker.Mode = UIDatePickerMode.Date;

            modalPicker.OnModalPickerDismissed += (s, ea) => 
            {
                var dateFormatter = new NSDateFormatter()
                {
                    DateFormat = "MMMM dd, yyyy"
                };

                textField.Text = dateFormatter.ToString(modalPicker.DatePicker.Date);
            };

            PresentViewController(modalPicker, true, null);

            return false;
        }
        private void PresentDatePicker(UITextField sender, DatePickerType pickerType, string pickerTitle, UIColor pickerTitleColor)
	    {
            DateTime selectedTime = DateTime.Parse(sender.Text);
            NSDate selectedDate = DateTimeToNSDate(selectedTime);

            var modalPicker = new ModalPickerViewController(ModalPickerType.Date, pickerTitle.Localize(), this)
            {
                HeaderBackgroundColor = pickerTitleColor,
                HeaderTextColor = UIColor.White,
                TransitioningDelegate = new ModalPickerTransitionDelegate(),
                ModalPresentationStyle = UIModalPresentationStyle.Custom
            };
            modalPicker.DatePicker.Date = selectedDate;

            modalPicker.OnModalPickerDismissed += (o, args) =>
            {
                DateTime utcDateTime = NSDateToDateTime(modalPicker.DatePicker.Date);
                if (pickerType == DatePickerType.StartDate)
                {
                    Event.StartDate = utcDateTime;
                }
                else if (pickerType == DatePickerType.EndDate)
                {
                    Event.EndDate = utcDateTime;
                }
                DateTime localDateTime = utcDateTime.ToLocalTime();
                sender.Text = localDateTime.ToShortDateString() + " " + localDateTime.ToShortTimeString();
            };
            PresentViewController(modalPicker, true, null);
	    }