[Peek] Handle ThemeListener ctor exceptions (#27110)

This commit is contained in:
Andrey Nekrasov 2023-06-30 10:50:12 +02:00 committed by GitHub
parent 345486acda
commit cc83e2b3ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,15 +27,22 @@ namespace Peek.UI
{
public MainWindowViewModel ViewModel { get; }
private ThemeListener themeListener;
private ThemeListener? themeListener;
public MainWindow()
{
InitializeComponent();
this.Activated += PeekWindow_Activated;
themeListener = new ThemeListener();
themeListener.ThemeChanged += (_) => HandleThemeChange();
try
{
themeListener = new ThemeListener();
themeListener.ThemeChanged += (_) => HandleThemeChange();
}
catch (Exception e)
{
Logger.LogError($"HandleThemeChange exception. Please install .NET 4.", e);
}
ViewModel = App.GetService<MainWindowViewModel>();