Skip to content

Instantly share code, notes, and snippets.

@gpeipman
Created August 10, 2019 05:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gpeipman/cfc99a613d4397406b2d62c48684a09b to your computer and use it in GitHub Desktop.
Save gpeipman/cfc99a613d4397406b2d62c48684a09b to your computer and use it in GitHub Desktop.
public interface IViewModel : INotifyPropertyChanged
{
}
public class MvvmComponentBase : ComponentBase
{
private IViewModel _viewModel;
public IViewModel ViewModel
{
get { return _viewModel; }
set
{
if(value != null)
{
_viewModel.PropertyChanged -= (o, e) => StateHasChanged();
value.PropertyChanged += (o, e) => StateHasChanged();
}
_viewModel = value;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment