laatzen/Common/Ui/Common.UI/Infrastructure/BaseViewModel[T].cs
2024-11-13 15:50:04 +01:00

22 lines
696 B
C#

namespace Common.UI.Infrastructure
{
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;
internal abstract class BaseViewModel<T> : INotifyPropertyChanged where T : BaseViewModel<T>
{
public event PropertyChangedEventHandler PropertyChanged;
protected void Set(Action<T> propertySetterCallback, [CallerMemberName] string property = null)
{
propertySetterCallback?.Invoke(this as T);
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
}
protected void InvokeAsync(Action callback)
=> App.Current.Dispatcher.InvokeAsync(callback);
}
}