RadCombobox Clear selection doesn't clear SelectedValue property.

3 posts, 1 answers
  1. Nikhil
    Nikhil avatar
    7 posts
    Member since:
    Aug 2012

    Posted 13 Feb 2013 Link to this post


    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" 
    telerik:StyleManager.Theme="{StaticResource Theme}" Grid.Row="1"
            ItemsSource="{Binding ProviderList}"
            SelectedValue="{Binding SelectedImmunVaccineDose.AdminByProvider, Mode=TwoWay}" 
    SelectedValuePath="Code" />    
    I am using MVVM Pattern :

     private ImmunizationVaccineDose _selectedImmunVaccineDose;
    public ImmunizationVaccineDose SelectedImmunVaccineDose 

    { return _selectedImmunVaccineDose; } 
    { if (_selectedImmunVaccineDose != value) 
    { _selectedImmunVaccineDose = value; 
    } } 
    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. Answer
    Alek avatar
    78 posts

    Posted 14 Feb 2013 Link to this post

    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.

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. Nikhil
    Nikhil avatar
    7 posts
    Member since:
    Aug 2012

    Posted 15 Feb 2013 Link to this post

    Thanks Alek for sample code. I implemented the way I wanted in my application using Converter.
Back to Top