public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { var desc = value as string; var returnValue = ChartTypeViewModelSource.GetCumulativeChartViewModels() .Concat(ChartTypeViewModelSource.GetDistributedChartViewModels()) .FirstOrDefault(x => x.Description == desc); return(returnValue ?? new EnumerableViewModel <ChartType>(ChartType.None, "None")); }
public HistoricalUsageStatsViewModel() { _isCumulativeChartCategoryActive = this.ObservableForProperty(vm => vm.ChartCategory, skipInitial: false) .Select(prop => prop.Value == ChartCategory.Cumulative) .ToProperty(this, vm => vm.IsCumulativeChartCategoryActive); _isDistributedChartCategoryActive = this.ObservableForProperty(vm => vm.ChartCategory, skipInitial: false) .Select(prop => prop.Value == ChartCategory.Distributed) .ToProperty(this, vm => vm.IsDistributedChartCategoryActive); _chartTypes = this.ObservableForProperty(vm => vm.ChartCategory, skipInitial: false) .Select(prop => prop.Value == ChartCategory.Cumulative ? new ObservableCollection <string>(ChartTypeViewModelSource.GetCumulativeChartViewModels().Select(x => x.Description)) : new ObservableCollection <string>(ChartTypeViewModelSource.GetDistributedChartViewModels().Select(x => x.Description))) .ToProperty(this, vm => vm.ChartTypes); _chartUpdateBinding = this.WhenAnyValue(x => x.SelectedChartType, x => x.SourceDataFile, x => x.ChartCategory, x => x.MovingAveragePeriod, x => x.SelectedAggregationType) .Subscribe(_ => RefreshChartCommand?.Execute(null)); }