I have a situation where I initially want set all the items of a xamComboEditor to selected. The problem is that doing so is very slow. If there are 400 items, it takes 8 seconds, 32 seconds for 800 items, etc. I am using version 2012.1. My code looks very much like:
AllowMultipleSelection = true;CheckBoxVisibility = System.Windows.Visibility.Visible;IsEditable = false;ObservableCollection<string> values = new ObservableCollection<string>();for (int i = 0; i <= 400; ++i) { values.Add(i.ToString());}ItemsSource = values;foreach (ComboEditorItem item in items) { item.IsSelected = true;}
The loop where IsSelected is set to true is taking all the time.
Is there a better way to select all the items? The current slowness is making xamComboEditor unusable for what I want to do.
Hi Elena,
I have the same issue, except I'm using WPF and I'm adding the selected objects to the SelectedItems collection instead of setting the IsSelected to true.
Selecting the elements before the control is rendered is not an option.
Is there any other way to speed this up?
Otherwise this control is of no use to me too unfortunately.
Thanks for your help,
Ricardo
Hello stephe,
I was just wondering did you have a chance to try my suggestion. If you still need any assistance on the matter, please do not hesitate to ask.
I have been looking into your issue and I can suggest you perform the selection in the Loaded event of the control . This way all of the items will be marked as selected before the control is rendered and it won’t go through all of the visual items. You can notice that if you do the selection in the Loaded event of the XamComboEditor it will take less than a second to perform the selection:
private void combo_Loaded(object sender, RoutedEventArgs e) { start = DateTime.Now; foreach (ComboEditorItem item in combo.Items) { item.IsSelected = true; } //foreach (Item i in combo.ItemsSource) // combo.SelectedItems.Add(i); end = DateTime.Now; Debug.WriteLine(end - start); }
If you need any additional assistance with this matter or if this doesn’t suit your scenario please let me know.