コード例 #1
0
        /// <summary>
        /// Shows the dialog on a specific view
        /// </summary>
        /// <returns>The dialog async.</returns>
        /// <param name="view">The view</param>
        /// <param name="mode">Mode.</param>
        /// <param name="title">Title.</param>
        /// <param name="message">Message.</param>
        /// <param name="selectedDate">Selected date.</param>
        /// <param name="effectStyle">Effect style.</param>
        public static Task <DateTime?> ShowDialogAsync(UIView view, UIDatePickerMode mode, String title, String message, DateTime?selectedDate = null, UIBlurEffectStyle effectStyle = UIBlurEffectStyle.ExtraLight)
        {
            var tcs = new TaskCompletionSource <DateTime?> ();


            new NSObject().BeginInvokeOnMainThread(() => {
                var dialog = new XamDatePickerDialog(mode)
                {
                    Title           = title,
                    Message         = message,
                    BlurEffectStyle = effectStyle,
                    ConstantUpdates = false,
                };

                if (selectedDate.HasValue)
                {
                    dialog.SelectedDate = selectedDate.Value;
                }

                dialog.OnCancel += (object sender, EventArgs e) =>
                {
                    tcs.SetResult(null);
                };

                dialog.OnSelectedDateChanged += (object s, DateTime e) =>
                {
                    tcs.SetResult(dialog.SelectedDate);
                };

                dialog.Show(view);
            });

            return(tcs.Task);
        }
コード例 #2
0
		partial void ShowDatePicker (UIButton sender)
		{

			var dialog = new XamDatePickerDialog(UIDatePickerMode.DateAndTime)
			{
				Title = "Date Picker",
				Message = "Please Pick a date and time",
				BlurEffectStyle = UIBlurEffectStyle.ExtraLight,
				CancelButtonText = "Cancel",
				ConstantUpdates = false,
			};
				
			dialog.SelectedDate = new DateTime(1969,7,20,20,18,00,00);

			dialog.ButtonMode = ButtonMode.OkAndCancel;

			dialog.ValidateSubmit = (DateTime data)=>
			{
				return true;
			};

			dialog.OnSelectedDateChanged += (object s, DateTime e) => 
			{
				Console.WriteLine(e);
			};

			dialog.Show();

			// Static methods
//			var result = await XamDatePickerDialog.ShowDialogAsync(UIDatePickerMode.DateAndTime,"Date of Birth","Select your Date of Birth", new DateTime(1969,7,20,20,18,00,00) );
//
//			Console.WriteLine(result);
		}
コード例 #3
0
		/// <summary>
		/// Shows the dialog.
		/// </summary>
		/// <returns>The dialog.</returns>
		/// <param name="title">Title.</param>
		/// <param name="message">Message.</param>
		/// <param name="selectedDate">Selected date.</param>
		/// <param name="effectStyle">Effect style.</param>
		public static Task<DateTime?> ShowDialogAsync(UIDatePickerMode mode, String title, String message, DateTime? selectedDate = null, UIBlurEffectStyle effectStyle = UIBlurEffectStyle.ExtraLight)
		{
			var tcs = new TaskCompletionSource<DateTime?> ();


			new NSObject ().BeginInvokeOnMainThread (() => {

				var dialog = new XamDatePickerDialog(mode)
				{
					Title = title,
					Message = message,
					BlurEffectStyle = effectStyle,
					ConstantUpdates = false,
				};

				if (selectedDate.HasValue)
					dialog.SelectedDate = selectedDate.Value;

				dialog.OnCancel += (object sender, EventArgs e) => 
				{
					tcs.SetResult(null);
				};

				dialog.OnSelectedDateChanged += (object s, DateTime e) => 
				{
					tcs.SetResult(dialog.SelectedDate);
				};

				dialog.Show();

			});

			return tcs.Task;
		}