diff --git a/src/CSharp/EasyMicroservices.UI.Core.Mvvm/BaseViewModel.cs b/src/CSharp/EasyMicroservices.UI.Core.Mvvm/BaseViewModel.cs index 412d7b2..438aaae 100644 --- a/src/CSharp/EasyMicroservices.UI.Core.Mvvm/BaseViewModel.cs +++ b/src/CSharp/EasyMicroservices.UI.Core.Mvvm/BaseViewModel.cs @@ -9,12 +9,21 @@ namespace EasyMicroservices.UI.Core; /// /// /// -public abstract class BaseViewModel : IBusyViewModel, INotifyPropertyChanged +public abstract class BaseViewModel : IBusyViewModel, INotifyPropertyChanged, IDisposable { + /// + /// + /// + public BaseViewModel() + { + PropertyChanged += BaseViewModel_PropertyChanged; + } + /// /// /// public Action OnBusyChanged { get; set; } + Action _OnBindPropertyChanged; bool _IsBusy; /// @@ -159,4 +168,26 @@ public virtual Task DisplayError(string message) { return Task.CompletedTask; } + + /// + /// + /// + /// + public virtual void BindPropertyChanged(Action action) + { + _OnBindPropertyChanged = action; + } + + private void BaseViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + _OnBindPropertyChanged?.Invoke(); + } + + /// + /// + /// + public virtual void Dispose() + { + PropertyChanged -= BaseViewModel_PropertyChanged; + } } diff --git a/src/CSharp/EasyMicroservices.UI.Core.Mvvm/EasyMicroservices.UI.Core.Mvvm.csproj b/src/CSharp/EasyMicroservices.UI.Core.Mvvm/EasyMicroservices.UI.Core.Mvvm.csproj index 28a4e5b..467353d 100644 --- a/src/CSharp/EasyMicroservices.UI.Core.Mvvm/EasyMicroservices.UI.Core.Mvvm.csproj +++ b/src/CSharp/EasyMicroservices.UI.Core.Mvvm/EasyMicroservices.UI.Core.Mvvm.csproj @@ -5,7 +5,7 @@ AnyCPU;x64;x86 EasyMicroservices true - 0.0.0.4 + 0.0.0.5 Model View View Model EasyMicroservices@gmail.com mvvm,mvpvm,modelview,modelviewviewmodel