Skip to content

Commit

Permalink
Merge pull request #5 from Ali-YousefiTelori/develop
Browse files Browse the repository at this point in the history
Support for BindPropertyChanged
  • Loading branch information
Ali-YousefiTelori authored Nov 13, 2023
2 parents 49d9511 + 2f12b52 commit f8af658
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 f8af658

Please sign in to comment.