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.
45 lines
1.1 KiB
45 lines
1.1 KiB
using System; |
|
using System.Threading.Tasks; |
|
using AsyncAwaitBestPractices; |
|
using CommunityToolkit.Mvvm.ComponentModel; |
|
using StabilityMatrix.Avalonia.Models; |
|
|
|
namespace StabilityMatrix.Avalonia.ViewModels.Base; |
|
|
|
public class ViewModelBase : ObservableValidator, IRemovableListItem |
|
{ |
|
private WeakEventManager? parentListRemoveRequestedEventManager; |
|
|
|
public event EventHandler ParentListRemoveRequested |
|
{ |
|
add |
|
{ |
|
parentListRemoveRequestedEventManager ??= new WeakEventManager(); |
|
parentListRemoveRequestedEventManager.AddEventHandler(value); |
|
} |
|
remove => parentListRemoveRequestedEventManager?.RemoveEventHandler(value); |
|
} |
|
|
|
protected void RemoveFromParentList() => parentListRemoveRequestedEventManager?.RaiseEvent( |
|
this, EventArgs.Empty, nameof(ParentListRemoveRequested)); |
|
|
|
public virtual void OnLoaded() |
|
{ |
|
|
|
} |
|
|
|
public virtual Task OnLoadedAsync() |
|
{ |
|
return Task.CompletedTask; |
|
} |
|
|
|
public virtual void OnUnloaded() |
|
{ |
|
|
|
} |
|
|
|
public virtual Task OnUnloadedAsync() |
|
{ |
|
return Task.CompletedTask; |
|
} |
|
}
|
|
|