-
Notifications
You must be signed in to change notification settings - Fork 101
Closed
Description
In the example, there is a strong dependency on the view layer TopLevel.GetTopLevel(this)
to ensure that the popup appears on top.
Ursa.Avalonia/demo/Ursa.Demo/Pages/ToastDemo.axaml.cs
Lines 19 to 31 in 1d0bfe9
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) | |
{ | |
base.OnAttachedToVisualTree(e); | |
var topLevel = TopLevel.GetTopLevel(this); | |
_viewModel.ToastManager = new WindowToastManager(topLevel) { MaxItems = 3 }; | |
} | |
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) | |
{ | |
base.OnDetachedFromVisualTree(e); | |
_viewModel.ToastManager?.Uninstall(); | |
} | |
} |
However, I am currently using
HttpClient
to request API interfaces. When the API interface returns an error, I want to globally toast a prompt (not in ViewModels
, but in a common method encapsulated in a separate class DelegatingHandler
). What should I do in this case?At present, the only method I can think of is to use
WeakReferenceMessenger
for message passing, but is there a more convenient method?Metadata
Metadata
Assignees
Labels
No labels