Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disposable View-Models and Services
public abstract class MasterDetailViewModel<TItemViewModel, TItem> : ViewModelBase, IDisposable where TItemViewModel : IItemViewModel<TItem> where TItem : class
{
public MasterDetailViewModel(
IItemsService<TItem> itemsService,
IItemToViewModelMap<TItem, TItemViewModel> viewModelMap,
IShowProgressInfo showProgressInfo,
ILoggerFactory loggerFactory)
: base(showProgressInfo)
{
//...
_itemsService.SelectedItemChanged += ItemsService_SelectedItemChanged;
_itemsService.PropertyChanged += ItemsService_PropertyChanged;
//...
}
public virtual void Dispose()
{
_itemsService.SelectedItemChanged -= ItemsService_SelectedItemChanged;
_itemsService.PropertyChanged -= ItemsService_PropertyChanged;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment