private void Deregister(BaseViewModel oldViewModel) { PagedViewModelWithPopups old = oldViewModel as PagedViewModelWithPopups; if (old != null) { old.Popups.CollectionChanged -= _popupsCollectionChangedHandler; old.CurrentPopupAllowsLightDismissChanged -= CurrentPopupAllowsLightDismissChanged; } }
protected override void OnViewModelChanged(PagedViewModel oldViewModel, PagedViewModel currentViewModel) { _listPresenter.ViewModels = ViewModel?.Popups; Deregister(oldViewModel); if (_popupsCollectionChangedHandler == null) { _popupsCollectionChangedHandler = new WeakEventHandler <NotifyCollectionChangedEventArgs>(Popups_CollectionChanged).Handler; } PagedViewModelWithPopups newModel = currentViewModel as PagedViewModelWithPopups; if (newModel != null) { newModel.Popups.CollectionChanged += _popupsCollectionChangedHandler; newModel.CurrentPopupAllowsLightDismissChanged += CurrentPopupAllowsLightDismissChanged; } UpdateVisibility(); UpdateLightDismiss(); base.OnViewModelChanged(oldViewModel, currentViewModel); }