private IEnumerable <IDisposable> Binding() { yield return(DocumentManagerViewModel.WhenAnyValue(x => x.IsBusy).Subscribe(isBusy => IsBusy = isBusy)); yield return (this.WhenAnyValue(x => x.HasDocument) .Where(doc => doc != null) .Subscribe(DocumentManagerViewModel.SetHasDocument)); yield return (this.WhenAny(x => x.SelectedDocument).Where(doc => doc != null && doc.Content == null).Subscribe( doc => { var loader = new AsyncRunner <byte[]>(); loader.RegisterFunction( () => { using (IUnitOfWork unitOfWork = this._unitOfWorkFactory.Create()) { var service = unitOfWork.Create <IAttachedDocumentService>(); return service.GetContent(doc.Rn); } }); var bytes = loader.GetInvokedTask().Result; if (bytes == null || bytes.Length == 0) { doc.Content = null; } else { doc.Content = bytes; } })); }