33 lines
1023 B
C#
33 lines
1023 B
C#
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
|
|
namespace MauiAppStock.ViewModels
|
|
{
|
|
public class BaseViewModel : INotifyPropertyChanged
|
|
{
|
|
bool isBusy;
|
|
public bool IsBusy
|
|
{
|
|
get => isBusy;
|
|
set => SetProperty(ref isBusy, value);
|
|
}
|
|
|
|
protected bool SetProperty<T>(ref T backingStore, T value, [CallerMemberName] string propertyName = "", System.Action onChanged = null)
|
|
{
|
|
if (EqualityComparer<T>.Default.Equals(backingStore, value))
|
|
return false;
|
|
|
|
backingStore = value;
|
|
onChanged?.Invoke();
|
|
OnPropertyChanged(propertyName);
|
|
return true;
|
|
}
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
protected void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|
{
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
} |