diff --git a/QuestPDF.Previewer/DocumentPreviewerExtensions.cs b/QuestPDF.Previewer/DocumentPreviewerExtensions.cs index 1a335ac..29f3f70 100644 --- a/QuestPDF.Previewer/DocumentPreviewerExtensions.cs +++ b/QuestPDF.Previewer/DocumentPreviewerExtensions.cs @@ -1,4 +1,5 @@ using Avalonia; +using Avalonia.Controls.ApplicationLifetimes; using QuestPDF.Infrastructure; namespace QuestPDF.Previewer @@ -17,6 +18,19 @@ namespace QuestPDF.Previewer { ArgumentNullException.ThrowIfNull(document); + //Currently there is no way to unitialize a previously run avalonia app. + //So we need to check if the previewer was already run and show the window again. + if(Application.Current?.ApplicationLifetime is ClassicDesktopStyleApplicationLifetime desktop) + { + desktop.MainWindow = new PreviewerWindow() + { + Document = document, + }; + desktop.MainWindow.Show(); + desktop.Start(Array.Empty()); + return; + } + AppBuilder .Configure(() => new PreviewerApp() {