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

RadCombobox Clear selection return invalid value

5 Answers 116 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
saurabh
Top achievements
Rank 1
saurabh asked on 04 Aug 2011, 11:24 AM
I am using a RadComboBox in my silverlight application. On the selection of item, we fill other control i.e TextBox in my case (Like based on selection of template display corrosponding value in Narrativ TextBox Field). when I select "clear Button" of combobox I want to clear TextBox Too.Suppose I select the first value from the combobox and based on that it set corrosponding value in textbox. But when I select clear button it return previous value or First Value of selected combobox. So I have implemented the following code :

<telerik:RadComboBox x:Name="notetemplate"

 

 

IsEnabled="{Binding IsNoteTypeEnabled, Mode=TwoWay}"

 

ItemsSource="{Binding FilteredNoteTemplates, Mode=TwoWay}"

 

DisplayMemberPath="NoteTypeKey"

 

SelectedValuePath="NoteTemplateId"

 

SelectedValue="{Binding NoteTemplateId, Mode=TwoWay}"

 

Command="{Binding NoteTemplateCommand}"

 

HorizontalAlignment="Stretch"

 

Style="{StaticResource McRadComboBoxStyle}"

 

TabIndex="2"

ClearSelectionButtonVisibility="Visible" ClearSelectionButtonContent="Clear"
/>

 
I am using MVVM Pattern :

private

 

 

Guid _noteTemplateId;

 

public Guid NoteTemplateId

{

 

get

{

 

if (_noteTemplateId == Guid.Empty)

{

Narrative =

 

string.Empty;

}

NotifyPropertyChanged(

 

"Narrative");

 

return _noteTemplateId;

}

 

set

{

_noteTemplateId =

 

value;

}

}

Onselection of clear button it should return GUID.Empty but all the time it return pervious selected value. so plese let me know how can we implement my logic.

 

 

5 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 08 Aug 2011, 01:59 PM
Hi Saurabh,

I've tried to reproduce this issue,  but without much success, please check the attached project for a reference.
If you still experience the issue, please send us a runnable code where it can be reproduced.

Regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Eric
Top achievements
Rank 1
answered on 13 Sep 2011, 09:58 PM
I have the same scenario that is listed above.
EXCEPT i have 2 Combo boxes

One (State) as a String as the Selected Value  and works as expected
the Second one as an Integer as the Selected Value and demonstrates the same issue
When you hit Clear Selection that textbox is cleared, but the updated value is not passed to the MVVM.

Any help on how to fix this would be greatly appreciated.
0
Yana
Telerik team
answered on 19 Sep 2011, 08:50 AM
Hello Eric,

Could you please open a support ticket and send us a simple project demonstrating this issue there? Thanks

Best wishes,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Henri
Top achievements
Rank 1
answered on 07 Oct 2011, 04:04 PM
I have the same issue.

<

telerik:RadComboBox
ItemsSource
="{Binding SomeObjects}"

 ClearSelectionButtonVisibility="Visible"

 ClearSelectionButtonContent="No filter"

 DisplayMemberPath="Stringproperty"

 SelectedValuePath="IntegerProperty"

 SelectedValue="{Binding SelectedInteger, Mode=TwoWay}"

 Margin="0,0,0,8"/>

 


When selecting 'No Filter' (thus clear), the view model is not called.
(using latest int.build 2011.2.1004.1040)

Update: Forget it, the reason is that clear will try to set null to the SelectedInteger and this fails.
Using an int? in the viewmodel, then no problem.

Henri
0
Yana
Telerik team
answered on 10 Oct 2011, 08:35 AM
Hello Henri,

I'm glad you could find the solution by yourself.

Regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
ComboBox
Asked by
saurabh
Top achievements
Rank 1
Answers by
Yana
Telerik team
Eric
Top achievements
Rank 1
Henri
Top achievements
Rank 1
Share this question
or