You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
663 B
24 lines
663 B
using AsyncAwaitBestPractices; |
|
using Avalonia.Controls; |
|
using Avalonia.Interactivity; |
|
using StabilityMatrix.Avalonia.ViewModels; |
|
|
|
namespace StabilityMatrix.Avalonia.Controls; |
|
|
|
public class UserControlBase : UserControl |
|
{ |
|
static UserControlBase() |
|
{ |
|
LoadedEvent.AddClassHandler<UserControlBase>( |
|
(cls, args) => cls.OnLoadedEvent(args)); |
|
} |
|
|
|
protected virtual void OnLoadedEvent(RoutedEventArgs? e) |
|
{ |
|
if (DataContext is not ViewModelBase viewModel) return; |
|
|
|
// ReSharper disable once MethodHasAsyncOverload |
|
viewModel.OnLoaded(); |
|
viewModel.OnLoadedAsync().SafeFireAndForget(); |
|
} |
|
}
|
|
|