Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DataFedVM"/> class.
        /// </summary>
        protected DataFedVM()
        {
            ControlsThatCurrentlyRequireThisVM = new ObservableCollection<object>();

            ObservationState = new BehaviorSubject<ObservationState>(Common.Models.ObservationState.Suspended);

            //Sets up ObservationState to turn Active when there are >0 controls that require this VM 
            //and inactive when there are 0 controls that require this VM
            ControlsThatCurrentlyRequireThisVM.FromCollectionChanged()
            .Select(args => ControlsThatCurrentlyRequireThisVM.Count > 0 ? Common.Models.ObservationState.Active : Common.Models.ObservationState.Suspended)
            .DistinctUntilChanged().Subscribe(state => ObservationState.OnNext(state));

            //Setup IsLoading property
            _isLoading = IsLoadingSubject.ToProperty(this, x => x.IsLoading);
        }