public async Task <LightContentDialogResult> ShowAsync() { if (System.Windows.Application.Current.MainWindow is FormsWindow window) { window.ShowContentDialog(this); LightContentDialogOpenedEventArgs lightContentDialogOpenedEventArgs = new LightContentDialogOpenedEventArgs(); Opened?.Invoke(this, lightContentDialogOpenedEventArgs); } LightContentDialogResult contentDialogResult = LightContentDialogResult.None; bool exit = false; while (!exit) { tcs = new TaskCompletionSource <LightContentDialogResult>(); contentDialogResult = await tcs.Task; exit = InternalHide(contentDialogResult); } return(contentDialogResult); }
//private void OnPrimaryButtonRoutedExecuted(object sender, ExecutedRoutedEventArgs e) //{ // LightContentDialogButtonClickEventArgs lightContentDialogButtonClickEventArgs = new LightContentDialogButtonClickEventArgs(); // PrimaryButtonClick?.Invoke(this, lightContentDialogButtonClickEventArgs); // if (!lightContentDialogButtonClickEventArgs.Cancel) // { // PrimaryButtonCommand?.Execute(PrimaryButtonCommandParameter); // tcs.TrySetResult(LightContentDialogResult.Primary); // } //} //private void SecondaryButtonRoutedExecuted(object sender, ExecutedRoutedEventArgs e) //{ // LightContentDialogButtonClickEventArgs lightContentDialogButtonClickEventArgs = new LightContentDialogButtonClickEventArgs(); // SecondaryButtonClick?.Invoke(this, lightContentDialogButtonClickEventArgs); // if (!lightContentDialogButtonClickEventArgs.Cancel) // { // SecondaryButtonCommand?.Execute(SecondaryButtonCommandParameter); // tcs.TrySetResult(LightContentDialogResult.Secondary); // } //} public async Task <LightContentDialogResult> ShowAsync() { if ((global::Avalonia.Application.Current.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime)?.MainWindow is FormsWindow window) { window.Show(); LightContentDialogOpenedEventArgs lightContentDialogOpenedEventArgs = new LightContentDialogOpenedEventArgs(); Opened?.Invoke(this, lightContentDialogOpenedEventArgs); } LightContentDialogResult contentDialogResult = LightContentDialogResult.None; bool exit = false; //while (!exit) //{ // tcs = new TaskCompletionSource<LightContentDialogResult>(); // contentDialogResult = await tcs.Task; // exit = InternalHide(contentDialogResult); //} return(contentDialogResult); }