ArgumentOutOfRangeException occurs when the ItemsSource of RadComboBox gets reset. To recreate this the IsSelected property of RadComboBoxItem should be bound too and multiple selection should be allowed.
To work this around, you can disable the autiomation peers globally:
AutomationManager.AutomationMode = AutomationMode.Disabled;
Or you disable them only for the RadComboBox:
public class CustomComboBox : RadComboBox
{
protected override AutomationPeer OnCreateAutomationPeer()
{
return null;
}
}
The stacktrace:
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')'
System.Private.CoreLib.dll!System.ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessException() Unknown
System.Private.CoreLib.dll!System.Collections.Generic.List<System.__Canon>.this[int].get(int index) Unknown Telerik.Windows.Controls.Input.dll!Telerik.Windows.Automation.Peers.RadComboBoxAutomationPeer.RaiseSelectionEvents(System.Windows.Controls.SelectionChangedEventArgs e) Line 202 C# Telerik.Windows.Controls.Input.dll!Telerik.Windows.Controls.RadComboBox.OnSelectionChanged(System.Windows.Controls.SelectionChangedEventArgs e) Line 1927 C#
PresentationFramework.dll!System.Windows.Controls.Primitives.Selector.SetSelectedHelper(object item, System.Windows.FrameworkElement UI, bool selected) Unknown
PresentationFramework.dll!System.Windows.Controls.Primitives.Selector.NotifyIsSelectedChanged(System.Windows.FrameworkElement container, bool selected, System.Windows.RoutedEventArgs e) Unknown
PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised) Unknown
PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender, System.Windows.RoutedEventArgs args) Unknown
Telerik.Windows.Controls.Input.dll!Telerik.Windows.Controls.RadComboBoxItem.OnSelected(System.Windows.RoutedEventArgs e) Line 59 C#
PresentationFramework.dll!System.Windows.Controls.ListBoxItem.OnIsSelectedChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) Unknown
PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) Unknown
WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) Unknown
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType) Unknown
PresentationFramework.dll!System.Windows.StyleHelper.ApplyStyleOrTemplateValue(MS.Internal.FrameworkObject fo, System.Windows.DependencyProperty dp) Unknown
PresentationFramework.dll!System.Windows.StyleHelper.InvalidateContainerDependents(System.Windows.DependencyObject container, ref MS.Utility.FrugalStructList<System.Windows.ContainerDependent> exclusionContainerDependents, ref MS.Utility.FrugalStructList<System.Windows.ContainerDependent> oldContainerDependents, ref MS.Utility.FrugalStructList<System.Windows.ContainerDependent> newContainerDependents) Unknown
PresentationFramework.dll!System.Windows.StyleHelper.DoStyleInvalidations(System.Windows.FrameworkElement fe, System.Windows.FrameworkContentElement fce, System.Windows.Style oldStyle, System.Windows.Style newStyle) Unknown
PresentationFramework.dll!System.Windows.StyleHelper.UpdateStyleCache(System.Windows.FrameworkElement fe, System.Windows.FrameworkContentElement fce, System.Windows.Style oldStyle, System.Windows.Style newStyle, ref System.Windows.Style styleCache) Unknown
PresentationFramework.dll!System.Windows.FrameworkElement.OnStyleChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) Unknown
PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) Unknown
WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) Unknown
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType) Unknown
WindowsBase.dll!System.Windows.DependencyObject.InvalidateProperty(System.Windows.DependencyProperty dp, bool preserveCurrentValue) Unknown
PresentationFramework.dll!System.Windows.FrameworkElement.UpdateStyleProperty() Unknown
PresentationFramework.dll!System.Windows.FrameworkElement.OnInitialized(System.EventArgs e) Unknown
Telerik.Windows.Controls.Input.dll!Telerik.Windows.Controls.RadComboBoxItem.OnInitialized(System.EventArgs e) Line 106 C#
PresentationFramework.dll!System.Windows.FrameworkElement.OnVisualParentChanged(System.Windows.DependencyObject oldParent) Unknown
PresentationFramework.dll!System.Windows.Controls.ListBoxItem.OnVisualParentChanged(System.Windows.DependencyObject oldParent) Unknown
PresentationCore.dll!System.Windows.Media.Visual.FireOnVisualParentChanged(System.Windows.DependencyObject oldParent) Unknown
PresentationCore.dll!System.Windows.Media.Visual.AddVisualChild(System.Windows.Media.Visual child) Unknown
PresentationCore.dll!System.Windows.Media.VisualCollection.Add(System.Windows.Media.Visual visual) Unknown
PresentationFramework.dll!System.Windows.Controls.UIElementCollection.AddInternal(System.Windows.UIElement element) Unknown
PresentationFramework.dll!System.Windows.Controls.Panel.GenerateChildren() Unknown
PresentationFramework.dll!System.Windows.Controls.Panel.OnItemsChangedInternal(object sender, System.Windows.Controls.Primitives.ItemsChangedEventArgs args) Unknown
PresentationFramework.dll!System.Windows.Controls.Panel.OnItemsChanged(object sender, System.Windows.Controls.Primitives.ItemsChangedEventArgs args) Unknown
PresentationFramework.dll!System.Windows.Controls.ItemContainerGenerator.OnRefresh() Unknown
PresentationFramework.dll!System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Unknown
WindowsBase.dll!System.Windows.WeakEventManager.ListenerList<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.DeliverEvent(object sender, System.EventArgs e, System.Type managerType) Unknown
WindowsBase.dll!System.Windows.WeakEventManager.DeliverEvent(object sender, System.EventArgs args) Unknown
PresentationFramework.dll!System.Windows.Data.CollectionView.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Unknown
WindowsBase.dll!System.Windows.WeakEventManager.ListenerList<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.DeliverEvent(object sender, System.EventArgs e, System.Type managerType) Unknown
WindowsBase.dll!System.Windows.WeakEventManager.DeliverEvent(object sender, System.EventArgs args) Unknown
PresentationFramework.dll!System.Windows.Data.CollectionView.OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs args) Unknown
PresentationFramework.dll!System.Windows.Data.ListCollectionView.RefreshOverride() Unknown
PresentationFramework.dll!System.Windows.Data.CollectionView.RefreshInternal() Unknown
PresentationFramework.dll!System.Windows.Data.CollectionView.DeferHelper.Dispose() Unknown
PresentationFramework.dll!System.Windows.Controls.ItemCollection.SetCollectionView(System.Windows.Data.CollectionView view) Unknown
PresentationFramework.dll!System.Windows.Controls.ItemsControl.OnItemsSourceChanged(System.Windows.DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e) Unknown
PresentationFramework.dll!System.Windows.FrameworkElement.OnPropertyChanged(System.Windows.DependencyPropertyChangedEventArgs e) Unknown
WindowsBase.dll!System.Windows.DependencyObject.NotifyPropertyChange(System.Windows.DependencyPropertyChangedEventArgs args) Unknown
WindowsBase.dll!System.Windows.DependencyObject.UpdateEffectiveValue(System.Windows.EntryIndex entryIndex, System.Windows.DependencyProperty dp, System.Windows.PropertyMetadata metadata, System.Windows.EffectiveValueEntry oldEntry, ref System.Windows.EffectiveValueEntry newEntry, bool coerceWithDeferredReference, bool coerceWithCurrentValue, System.Windows.OperationType operationType) Unknown
WindowsBase.dll!System.Windows.DependencyObject.InvalidateProperty(System.Windows.DependencyProperty dp, bool preserveCurrentValue) Unknown
PresentationFramework.dll!System.Windows.Data.BindingExpression.TransferValue(object newValue, bool isASubPropertyChange) Unknown
PresentationFramework.dll!MS.Internal.Data.PropertyPathWorker.UpdateSourceValueState(int k, System.ComponentModel.ICollectionView collectionView, object newValue, bool isASubPropertyChange) Unknown
PresentationFramework.dll!MS.Internal.Data.ClrBindingWorker.OnSourcePropertyChanged(object o, string propName) Unknown
WindowsBase.dll!System.Windows.WeakEventManager.ListenerList<System.ComponentModel.PropertyChangedEventArgs>.DeliverEvent(object sender, System.EventArgs e, System.Type managerType) Unknown
WindowsBase.dll!System.ComponentModel.PropertyChangedEventManager.OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs args) Unknown
Telerik.Windows.Controls.dll!Telerik.Windows.Controls.ViewModelBase.OnPropertyChanged(string propertyName) Unknown
> WpfApp180.dll!WpfApp180.MainViewModel.ResetData() Line 44 C#
Currently RadComboBox supports filtering of the data when IsEditable is True.
Add a mode where a search box is displayed (when IsEditable is False) in the drop down of the control. The searchbox should filter the items in the dropdown.
Currently filtering with virtualized RadComboBox is not supported as the filtering feature works with the containers (changes their Visibility).
Currently, the drop down of RadComboBox contains only the RadComboBoxItems and the Clear Selection button. Add new content presenter that allows you to include extra visuals, like buttons or text.
The feature is similar to the AdditionalContent of RadTabControl.
The exception message is the following: System.ArgumentException: 'The value '102' is not a valid value for the enum 'FilterOperator'.'
To work this around, avoid using mixed typed values in the ItemsSource.
The items of the RadComboBox control flicker when scrolling and the Windows 11 theme is applied.
To work this around, a new Style with TargetType="RadComboBoxItem" could be created for the ItemContainerStyle property of RadComboBox. Then, set the BorderBrush and ThemeHelper.MouseOverBrush properties to "#F9F9F9".
xmlns:helpers="clr-namespace:Telerik.Windows.Controls.Theming.Helpers;assembly=Telerik.Windows.Controls"
<telerik:RadComboBox.ItemContainerStyle>
<Style TargetType="telerik:RadComboBoxItem">
<Setter Property="helpers:ThemeHelper.MouseOverBrush" Value="#F9F9F9" />
<Setter Property="BorderBrush" Value="#F9F9F9"/>
</Style>
</telerik:RadComboBox.ItemContainerStyle>
The selected items of the RadComboBox will not be displayed correctly if the ItemsSource is bound to a collection of enums that are converted via a custom EnumConverter.
Currently, you could work around this behavior by implementing a custom DataTemplate for the MultipleSelectionBoxTemplate property of RadComboBox:
<telerik:RadComboBox x:Name="comboBox"
AllowMultipleSelection="True">
<telerik:RadComboBox.MultipleSelectionBoxTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding ElementName=comboBox, Path=SelectedItems}"
AlternationCount="{Binding RelativeSource={RelativeSource Self}, Path=Items.Count}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="commaTextBlock" Text=", "/>
<TextBlock Text="{Binding}" HorizontalAlignment="Left"/>
</StackPanel>
<DataTemplate.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Visibility" TargetName="commaTextBlock" Value="Collapsed" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</telerik:RadComboBox.MultipleSelectionBoxTemplate>
</telerik:RadComboBox>
Setting the Background property of RadComboBox no longer changes the background color of the control.
To work this around, you can add a global event handler for the Loaded event of RadComboBox and set the corresponding backgrounds in code.
static MainWindow()
{
EventManager.RegisterClassHandler(typeof(RadComboBox), RadComboBox.LoadedEvent, new RoutedEventHandler(OnComboBoxLoaded));
}
private static void OnComboBoxLoaded(object sender, RoutedEventArgs e)
{
var comboBox = (RadComboBox)sender;
if (!comboBox.IsEditable)
{
if (comboBox.IsEnabled)
{
var buttonChrome = comboBox.FindChildByType<ButtonChrome>();
buttonChrome.Background = Brushes.Purple;
}
else
{
comboBox.Background = Brushes.Purple;
}
}
}
Steps to Create Problem using EditableTextBoxTemplate_WPF sample project provided by Telerik:(modified project is zipped and attached just in case)
- Edit Example.xaml to add "AllowMultipleSelection="True":
<telerik:RadComboBox IsEditable="True" ItemsSource="{Binding Companies}" SelectAllTextEvent="None" FontFamily="Calibri" FontSize="14"
1) Run project
2) Click drop down button to see list in the drop down
3) Type "Global" (at this point it should autocomplete "Global Corporation")
4) Without clicking on anything or Press space bar to continue typing (type space character)
5) Typed text will disappear leaving only space character behind - At this point, nothing is selected.
This does NOT happen if typed text before space does NOT match with any item from the list.
This does NOT happen if AllowMultipleSelection set to false.
This does NOT happen if dropdown is NOT open while typing.
NullReferenceException appears when the multiple selection is enabled, items are selected and the Text property of the RadComboBox control becomes null.
To resolve this, you can override the OnTextChanged method of RadComboBox and replace the null value with an empty string.
public class CustomRadComboBox : RadComboBox
{
protected override void OnTextChanged(string oldValue, string newValue)
{
if (string.IsNullOrEmpty(newValue))
{
newValue = string.Empty;
Dispatcher.BeginInvoke(new Action(() =>
{
SelectedItems.Clear();
}));
}
base.OnTextChanged(oldValue, newValue);
}
}