public static void ClearAndAddRange <T>(this ObservableCollectionContentNotifying <T> input, IEnumerable <T> array) { input.SuspendNotification = true; input.Clear(); foreach (var o in array) { input.Add(o); } input.SuspendNotification = false; }
public MainViewModel() { InstanceConverter = new InstanceInSetToStringConverter(); LocationCollection = new ObservableCollectionContentNotifying <DemandLocation>(); ChartData = new ObservableCollectionContentNotifying <PlotTrend>(); LocationCollection.ClearAndAddRange(Selects.GetDemandLocations().Take(5)); var locs = new List <int> { 18, 55 }; locs.ForEach(x => LocationCollection.Single(y => y.LocationID == x).IsUsed = true); UpdateHeader(); SelectedItem = TrendChoices.FiscalPeriod; UpdateChartData(); LocationCollection.OnCollectionItemChanged += UpdateHeader; }
public ChartViewModel(Person person) { //Setup InstanceConverter = new InstanceInSetToStringConverter(); _person = person; _data = new List <spTransactionSummationByDuration_Result>(); Start = DateTime.Now.Date.AddMonths(-2); End = DateTime.Now.Date; Floor = 100; SelectedGrouping = GroupingFrequency.Month; SelectedChart = ChartType.BarChart; Categories = new ObservableCollectionContentNotifying <Category>(); InitialCategorySet(); ChartData = new ObservableCollectionContentNotifying <PlotTrend>(); UpdateChartDataForPlotTrends(); _loaded = true; }