Inheritance: System.Windows.Controls.ChildWindow
Example #1
0
        public static Task AlertUser(string title, string message)
        {
            var dataContext = new ConfirmModel
			{
				Title = title,
				Message = message,
                AllowCancel = false,
			};
			var inputWindow = new ConfirmWindow()
			{
				DataContext = dataContext
			};

			var tcs = new TaskCompletionSource<bool>();

			inputWindow.Closed += (sender, args) =>
			{
				if (inputWindow.DialogResult == true)
					tcs.SetResult(true);
				else
					tcs.SetCanceled();
			};

			inputWindow.Show();

			return tcs.Task;
        }
Example #2
0
		public static Task<bool> ConfirmationAsync(string title, string question)
		{
			var dataContext = new ConfirmModel
			{
				Title = title,
				Message = question
			};
			var inputWindow = new ConfirmWindow
			{
				DataContext = dataContext
			};

			var tcs = new TaskCompletionSource<bool>();

			inputWindow.Closed += (sender, args) =>
			{
				if (inputWindow.DialogResult != null)
					tcs.SetResult(inputWindow.DialogResult.Value);
				else
					tcs.SetCanceled();
			};

			inputWindow.Show();

			return tcs.Task;
		}