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.
46 lines
1.1 KiB
46 lines
1.1 KiB
1 year ago
|
using System;
|
||
|
using System.Threading.Tasks;
|
||
|
using AsyncAwaitBestPractices;
|
||
1 year ago
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||
1 year ago
|
using StabilityMatrix.Avalonia.Models;
|
||
1 year ago
|
|
||
1 year ago
|
namespace StabilityMatrix.Avalonia.ViewModels.Base;
|
||
1 year ago
|
|
||
1 year ago
|
public class ViewModelBase : ObservableValidator, IRemovableListItem
|
||
1 year ago
|
{
|
||
1 year ago
|
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));
|
||
|
|
||
1 year ago
|
public virtual void OnLoaded()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public virtual Task OnLoadedAsync()
|
||
|
{
|
||
|
return Task.CompletedTask;
|
||
|
}
|
||
1 year ago
|
|
||
|
public virtual void OnUnloaded()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public virtual Task OnUnloadedAsync()
|
||
|
{
|
||
|
return Task.CompletedTask;
|
||
|
}
|
||
1 year ago
|
}
|