void AddFilterStack4_batteryCapcityStack() { if (UpdatedListOfDevices.Length > 0) { PassedToStack4_batteryCapacityStack = UpdatedListOfDevices; TextBlock FilterLabel = new TextBlock { Text = " Select Battery Capacity " }; filter4StackLabel.Children.Add(FilterLabel); //Build the item list List <int> uniqueBatteryCapacities = new List <int>(); foreach (var device in UpdatedListOfDevices) { if (!uniqueBatteryCapacities.Contains(int.Parse(device.batterycapacity))) { uniqueBatteryCapacities.Add(int.Parse(device.batterycapacity)); } } Comparor comparorObj = new Comparor(); uniqueBatteryCapacities.Sort(comparorObj); foreach (var batteryCapacity in uniqueBatteryCapacities) { CheckBox cb = new CheckBox(); cb.Content = batteryCapacity; cb.Checked += new RoutedEventHandler(battery_filter_CheckBox_Clicked); cb.Unchecked += new RoutedEventHandler(battery_filter_CheckBox_Clicked); filter4Stack.Children.Add(cb); } } }
void AddFilterStack2_weightStack() { if (UpdatedListOfDevices.Length > 0) { PassedToStack2_weightsStack = UpdatedListOfDevices; List <int> selectedRanges = new List <int>(); selectedRanges = GetRangesToBeSelected(UpdatedListOfDevices); Comparor comparorObj = new Comparor(); selectedRanges.Sort(comparorObj); TextBlock FilterLabel = new TextBlock { Text = " Select Weight range " }; filter2StackLabel.Children.Add(FilterLabel); foreach (var range in selectedRanges) { CheckBox cb_temp = new CheckBox(); cb_temp.Content = weightRangesToShow[range].content; cb_temp.Checked += new RoutedEventHandler(weight_filter_CheckBox_Clicked); cb_temp.Unchecked += new RoutedEventHandler(weight_filter_CheckBox_Clicked); filter2Stack.Children.Add(cb_temp); } } }