private void ShowCalendar(DialogViewController dvc, UITableView tableView, NSIndexPath path) { if (calView == null) { calView = new CalendarMonthView(DateValue, true) { AutoresizingMask = UIViewAutoresizing.FlexibleWidth }; //calView.ToolbarColor = dvc.SearchBarTintColor; calView.SizeChanged += delegate { RectangleF screenRect = tableView.Window.Frame; SizeF pickerSize = calView.Size; // compute the end frame RectangleF pickerRect = new RectangleF(0.0f, screenRect.Y + screenRect.Size.Height - pickerSize.Height, pickerSize.Width, pickerSize.Height); // start the slide up animation UIView.BeginAnimations(null); UIView.SetAnimationDuration(0.3); // we need to perform some post operations after the animation is complete UIView.SetAnimationDelegate(dvc); calView.Frame = pickerRect; UIView.CommitAnimations(); }; } if (calView.Superview == null) { if (DateValue.Year < 2010) { DateValue = DateTime.Today; } calView.SizeThatFits(SizeF.Empty); calView.OnDateSelected += (date) => { DateValue = date; if (OnDateSelected != null) { OnDateSelected(date); } //Console.WriteLine(String.Format("Selected {0}", date.ToShortDateString())); if (closeOnSelect) { CloseCalendar(dvc, tableView, path); } }; tableView.Window.AddSubview(calView); //dvc.View.Window.AddSubview(datePicker); // // size up the picker view to our screen and compute the start/end frame origin for our slide up animation // // compute the start frame RectangleF screenRect = tableView.Window.Frame; SizeF pickerSize = calView.Size; RectangleF startRect = new RectangleF(0.0f, screenRect.Y + screenRect.Size.Height, pickerSize.Width, pickerSize.Height); calView.Frame = startRect; // compute the end frame RectangleF pickerRect = new RectangleF(0.0f, screenRect.Y + screenRect.Size.Height - pickerSize.Height, pickerSize.Width, pickerSize.Height); // start the slide up animation UIView.BeginAnimations(null); UIView.SetAnimationDuration(0.3); // we need to perform some post operations after the animation is complete UIView.SetAnimationDelegate(dvc); calView.Frame = pickerRect; // shrink the table vertical size to make room for the date picker RectangleF newFrame = new RectangleF(tableView.Frame.X, tableView.Frame.Y, tableView.Frame.Size.Width, tableView.Frame.Size.Height + 55 - calView.Frame.Height); // newFrame.Size.Height -= datePicker.Frame.Height; //tableView.Frame = newFrame; UIView.CommitAnimations(); rightOld = dvc.NavigationItem.RightBarButtonItem; //Multi Buttons // create a toolbar to have two buttons in the right UIToolbar tools = new UIToolbar(new RectangleF(0, 0, 133, 44.01f)); tools.TintColor = dvc.NavigationController.NavigationBar.TintColor; // create the array to hold the buttons, which then gets added to the toolbar List <UIBarButtonItem> buttons = new List <UIBarButtonItem>(3); // create switch button switchButton = new UIBarButtonItem("Switch", UIBarButtonItemStyle.Bordered, delegate { CloseCalendar(dvc, tableView, path); ShowDatePicker(dvc, tableView, path); }); buttons.Add(switchButton); // create a spacer UIBarButtonItem spacer = new UIBarButtonItem(UIBarButtonSystemItem.FixedSpace, null, null); buttons.Add(spacer); //create done button doneButton = new UIBarButtonItem("Done", UIBarButtonItemStyle.Done, delegate { //DateValue = calView.CurrentDate; CloseCalendar(dvc, tableView, path); }); buttons.Add(doneButton); tools.SetItems(buttons.ToArray(), false); // dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem(tools); leftOld = dvc.NavigationItem.LeftBarButtonItem; dvc.NavigationItem.LeftBarButtonItem = new UIBarButtonItem("None", UIBarButtonItemStyle.Bordered, delegate { DateValue = DateTime.MinValue; if (OnDateSelected != null) { OnDateSelected(CalendarDateTimeElement.DateTimeMin); } CloseCalendar(dvc, tableView, path); }); // add the "Done" button to the nav bar //dvc.NavigationItem.SetRightBarButtonItem(doneButton,true); // } }