feat: ensure notification manager is initialized.
This commit is contained in:
@@ -20,11 +20,10 @@ public partial class NotificationDemo : UserControl
|
|||||||
{
|
{
|
||||||
base.OnAttachedToVisualTree(e);
|
base.OnAttachedToVisualTree(e);
|
||||||
var topLevel = TopLevel.GetTopLevel(this);
|
var topLevel = TopLevel.GetTopLevel(this);
|
||||||
|
if (topLevel is null)
|
||||||
WindowNotificationManager.TryGetNotificationManager(topLevel, out var manager);
|
return;
|
||||||
if (manager is not null)
|
_viewModel.NotificationManager = WindowNotificationManager.TryGetNotificationManager(topLevel, out var manager)
|
||||||
{
|
? manager
|
||||||
_viewModel.NotificationManager = manager;
|
: new WindowNotificationManager(topLevel);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,10 +19,10 @@ public partial class MainView : UserControl
|
|||||||
base.OnAttachedToVisualTree(e);
|
base.OnAttachedToVisualTree(e);
|
||||||
_viewModel = DataContext as MainViewViewModel;
|
_viewModel = DataContext as MainViewViewModel;
|
||||||
var topLevel = TopLevel.GetTopLevel(this);
|
var topLevel = TopLevel.GetTopLevel(this);
|
||||||
WindowNotificationManager.TryGetNotificationManager(topLevel, out var manager);
|
if (topLevel is null || _viewModel is null)
|
||||||
if (manager is not null && _viewModel is not null)
|
return;
|
||||||
{
|
_viewModel.NotificationManager = WindowNotificationManager.TryGetNotificationManager(topLevel, out var manager)
|
||||||
_viewModel.NotificationManager = manager;
|
? manager
|
||||||
}
|
: new WindowNotificationManager(topLevel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user