Example #1
0
        private void SetupDatePicker()
        {
            // close button
            var doneButton = new UIBarButtonItem("close", UIBarButtonItemStyle.Done, (s, e) =>
            {
                // Close DatePicker
                DateText.ResignFirstResponder();
            });

            // toolbar
            var toolbar = new UIToolbar()
            {
                BarStyle    = UIBarStyle.Default,
                Translucent = true,
                TintColor   = null,
            };

            // add closebutton and space on Toolbar
            toolbar.SizeToFit();
            toolbar.SetItems(new []
            {
                // space adjust , flexiblespace leads to right align for done button.
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                doneButton,
            }, true);

            // datepicker
            var datePicker = new UIDatePicker()
            {
                Mode = UIDatePickerMode.Date,
            };

            // datepicker event
            datePicker.ValueChanged += (s, e) =>
            {
                MemoHolder.Current.Memo.Date = (DateTime)datePicker.Date;
                DisplayMemo();
            };

            // set toolbar and datepicker set
            DateText.InputAccessoryView = toolbar;
            DateText.InputView          = datePicker;
        }
Example #2
0
        private void SetupDatePicker()
        {
            var doneButton = new UIBarButtonItem("閉じる", UIBarButtonItemStyle.Done, (s, e) =>
            {
                //DateTextのDatePickerを閉じる
                DateText.ResignFirstResponder();
            });

            //閉じるボタンを乗せるツールバー
            var toolbar = new UIToolbar()
            {
                BarStyle    = UIBarStyle.Default,
                Translucent = true,
                TintColor   = null,
            };

            toolbar.SizeToFit();
            toolbar.SetItems(new[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                doneButton,
            }, true);

            //DatePicker
            var datePicker = new UIDatePicker()
            {
                Mode   = UIDatePickerMode.Date,
                Locale = new NSLocale("ja_JP"),
            };

            datePicker.ValueChanged += (s, e) =>
            {
                MemoHolder.Current.Memo.Date = (DateTime)datePicker.Date;
                DisplayMemo();
            };

            //DateTextに作成したツールバーとDatePickerをセットする
            DateText.InputAccessoryView = toolbar;
            DateText.InputView          = datePicker;
        }