Last Updated: 12 Jan 2022 07:37 by ADMIN
Created on: 05 Jan 2022 09:42
Category: UI for WPF
Type: Feature Request
ComboBox: Add a property that determines if the SelectedItem can become null

Currently RadComboBox has no property to prevent user from clearing it with backspace. Also ComboBox SelectedIndex may become -1 when ItemSource is changed.

New propery (CanClear) could be checked on KeyDown event, when item collection is changed or when SelectedItem is changed..

If CanClear is set to false:

Backspace is ignored on KeyDown.

If collection is changed and collection size is greater than 0, ComboBox SelectedIndex becomes 0 automatically.

If SelectedItem becomes null and item collection size is greater than 0, ComboBox attemts to select first non-null item from collection.

1 comment
Martin Ivanov
Posted on: 12 Jan 2022 07:37

Hello Alexandr,

Thank you for the feedback. I've changed the title slightly in order to be easier to be found from other users. 

In the meantime, you should be able to achieve your requirement by binding the SelectedItem to a property in your view model. And then, coercing the value of the property in the view model. If the value become null, you can return it back to the previous or any other value from the ItemsSource.

Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.