/// <summary> 显示蒙版 </summary> public static async Task <bool> ShowObjectWithPropertyForm <T>(T value, Predicate <T> match = null, string title = null) { bool result = false; await Application.Current.Dispatcher.Invoke(async() => { if (Application.Current.MainWindow is IWindowBase window) { ObjectPropertyForm form = new ObjectPropertyForm(); form.Title = title; form.Style = Application.Current.FindResource("S.ObjectPropertyForm.Default.WithSumit") as Style; form.SelectObject = value; form.Close += (l, k) => { CloseWithLayer(); _asyncShowWaitHandle.Set(); result = false; }; form.Sumit += (l, k) => { var check = form.ModelState(out List <string> errors); if (!check) { MessageService.ShowSnackMessageWithNotice(errors.FirstOrDefault()); return; } if (match != null && !match(value)) { return; } CloseWithLayer(); _asyncShowWaitHandle.Set(); result = true; }; window.ShowWithLayer(form); _asyncShowWaitHandle.Reset(); var task = new Task(() => { _asyncShowWaitHandle.WaitOne(); }); task.Start(); await task; } }); return(result); }
/// <summary> 显示蒙版 </summary> public static async Task <bool> ShowWithObject(object value, string title = null) { bool result = false; await Application.Current.Dispatcher.Invoke(async() => { if (Application.Current.MainWindow is IWindowBase window) { ObjectPropertyForm form = new ObjectPropertyForm(); form.Title = title; form.Style = Application.Current.FindResource("S.ObjectPropertyForm.Default.WithSumit") as Style; form.SelectObject = value; form.Close += (l, k) => { CloseWithLayer(); _asyncShowWaitHandle.Set(); result = false; }; form.Sumit += (l, k) => { CloseWithLayer(); _asyncShowWaitHandle.Set(); result = true; }; window.ShowWithLayer(form); _asyncShowWaitHandle.Reset(); var task = new Task(() => { _asyncShowWaitHandle.WaitOne(); }); task.Start(); await task; } }); return(result); }