This is a migrated thread and some comments may be shown as answers.

RadComboBox Validation

1 Answer 562 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Veteran
Lee asked on 30 Mar 2021, 07:50 PM

Hey everyone,

I'm currently working through some existing project, and would like to set up a RadComboBox that will complain if it doesn't have a current selection, or the current selection is an empty string. The current ComboBox is the stock WPF control, and populates itself like this:

const string sql = @"
    SELECT Item AS ListItem
    FROM...";
DataTable table = GetTable(...)
 
cbx.ItemsSource = table.DefaultView;
cbx.DisplayMemberPath = "Item";
cbx.SelectedValuePath = "Item";

 

I'm new to MVVM and WPF, and this doesn't seem standard. So, what I want to know is if there's a nice way to have the RadComboBox control complain about an invalid SelectedItem? Do I need to rip this apart and do data binding? If so, is there an example I can look at to get an idea?

As always, thanks for the help,

Lee

1 Answer, 1 is accepted

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 02 Apr 2021, 09:37 AM

Hello Lee,

Thank you for the code snippet.

I have prepared a sample project to demonstrate how you can validate the selected item. You can find the project attached to this reply. When you run the project, you need to select a car, otherwise, a red border will appear. 

I hope that this project will be helpful.

Regards,
Dinko
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/.

Tags
ComboBox
Asked by
Lee
Top achievements
Rank 1
Veteran
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or