Skip to content

Commit

Permalink
Support for BindPropertyChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali-YousefiTelori committed Nov 13, 2023
1 parent 67f9547 commit 2f12b52
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
33 changes: 32 additions & 1 deletion src/CSharp/EasyMicroservices.UI.Core.Mvvm/BaseViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ namespace EasyMicroservices.UI.Core;
/// <summary>
///
/// </summary>
public abstract class BaseViewModel : IBusyViewModel, INotifyPropertyChanged
public abstract class BaseViewModel : IBusyViewModel, INotifyPropertyChanged, IDisposable
{
/// <summary>
///
/// </summary>
public BaseViewModel()
{
PropertyChanged += BaseViewModel_PropertyChanged;
}

/// <summary>
///
/// </summary>
public Action<bool> OnBusyChanged { get; set; }
Action _OnBindPropertyChanged;

bool _IsBusy;
/// <summary>
Expand Down Expand Up @@ -159,4 +168,26 @@ public virtual Task DisplayError(string message)
{
return Task.CompletedTask;
}

/// <summary>
///
/// </summary>
/// <param name="action"></param>
public virtual void BindPropertyChanged(Action action)
{
_OnBindPropertyChanged = action;
}

private void BaseViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
_OnBindPropertyChanged?.Invoke();
}

/// <summary>
///
/// </summary>
public virtual void Dispose()
{
PropertyChanged -= BaseViewModel_PropertyChanged;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Platforms>AnyCPU;x64;x86</Platforms>
<Authors>EasyMicroservices</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.0.0.4</Version>
<Version>0.0.0.5</Version>
<Description>Model View View Model</Description>
<Copyright>[email protected]</Copyright>
<PackageTags>mvvm,mvpvm,modelview,modelviewviewmodel</PackageTags>
Expand Down

0 comments on commit 2f12b52

Please sign in to comment.