Hi,
For a XamComboEditor with multiple selection enabled - what would be the best way to show a different text such as "All items" when the user has selected all the items from the dropdown?
Thanks.
Hello Ribao80,
In order to display a custom text inside the XamComboEditor whenever all items are selected, you can handle the SelectionChanged event and perform a manual check if the total items count equals the selected items count. If the check passes, you can simply get the horizontal StackPanel that is responsible for filling the combo with the selected values and clear it. This way you can add a single TextBlock with the respective Text property set to the desired text.
private void combo_SelectionChanged(object sender, Infragistics.Controls.Editors.SelectionChangedEventArgs e){ var comboEditor = sender as XamComboEditor; if (comboEditor == null) return; if (comboEditor.Items.Count == combo.SelectedItems.Count) { var panel = Utilities.GetDescendantFromName(comboEditor, "MultiSelectContentPanel") as StackPanel; panel.Children.Clear(); panel.Children.Add(new TextBlock() { Text = "All items" }); }}
if (comboEditor.Items.Count == combo.SelectedItems.Count) { var panel = Utilities.GetDescendantFromName(comboEditor, "MultiSelectContentPanel") as StackPanel; panel.Children.Clear(); panel.Children.Add(new TextBlock() { Text = "All items" }); }}
I have attached a sample application that uses the approach from above.
If you have any questions, please let me know.