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

RadCombobox Clear selection doesn't clear SelectedValue property.

2 Answers 259 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Nikhil
Top achievements
Rank 1
Nikhil asked on 13 Feb 2013, 02:10 PM
Hi,

I am using a RadComboBox in my silverlight application. When I select "Clear Button" of combobox, the property used for SelectedValue is not becoming null, This is because, the 

SelectedValue property is of non-nullable type. So, when I select clear button it return previous value of selected combobox. I have implemented the following code :

<telerik:RadComboBox ClearSelectionButtonContent="Clear" 
ClearSelectionButtonVisibility="Visible" 
telerik:StyleManager.Theme="{StaticResource Theme}" Grid.Row="1"
        Grid.Column="2" 
        DisplayMemberPath="Name"
        ItemsSource="{Binding ProviderList}"
        SelectedValue="{Binding SelectedImmunVaccineDose.AdminByProvider, Mode=TwoWay}" 
SelectedValuePath="Code" />    
 
I am using MVVM Pattern :

 private ImmunizationVaccineDose _selectedImmunVaccineDose;
public ImmunizationVaccineDose SelectedImmunVaccineDose 

get 
{ return _selectedImmunVaccineDose; } 
set 
{ if (_selectedImmunVaccineDose != value) 
{ _selectedImmunVaccineDose = value; 
RaisePropertyChanged("SelectedImmunVaccineDose"); 
} } 
}
The type 'ImmunizationVaccineDose' is a Entity Class, which I can't modify. 
SelectedItem can be used instead of SelectedValue but I don't want to create un-necessary 
properties in View Model just for binding purpose since there are a lot of such RadComboBoxes 
throughout my application where Clear functionality has to be working.

Is there any way to clear SelectedValue property?
Please let me know some solution by which we can achieve this. Thanks... 

2 Answers, 1 is accepted

Sort by
0
Accepted
Alek
Telerik team
answered on 14 Feb 2013, 02:01 PM
Hi Nikhil,

Such behavior from RadComboBox is expected.

We are not exactly sure what do you expect to happen with the SelectedValue's data after using the Clear button?

A possible approach is to use a Converter. For the example we are sending you we are using DateTime which cannot be Nullable too (see the attachment). Please take a look at it.

We hope that the solution will fit with your needs.

Regards,
Alek
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Nikhil
Top achievements
Rank 1
answered on 15 Feb 2013, 09:32 AM
Thanks Alek for sample code. I implemented the way I wanted in my application using Converter.
Tags
ComboBox
Asked by
Nikhil
Top achievements
Rank 1
Answers by
Alek
Telerik team
Nikhil
Top achievements
Rank 1
Share this question
or