I want to have null as an option in a Combobox, but I can´t figure out how to do that. I´m using MVVM and adds a null value at index 0 to my bounded IList : regioner.Insert(0, null);
Nothing crashes but the user can´t choose the null item.
Best regards / Anna
Nothing crashes but the user can´t choose the null item.
Best regards / Anna
5 Answers, 1 is accepted
0
Hi Anna Rudlund,
You could set ClearSelectionButtonVisibility to Visible and ClearSelectionButtonContent to the content that will be shown in this button. Then when the user click on this button the selected item will be null.
There is no need to add NULL item in your data source.
Let us know if you need more information.
Kind regards,
Hristo
the Telerik team
You could set ClearSelectionButtonVisibility to Visible and ClearSelectionButtonContent to the content that will be shown in this button. Then when the user click on this button the selected item will be null.
There is no need to add NULL item in your data source.
Let us know if you need more information.
Kind regards,
Hristo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Rudis
Top achievements
Rank 1
answered on 21 Jun 2010, 08:12 AM
Thanx!
That works perfekt! Just was I was looking for.
Best regards / Anna
That works perfekt! Just was I was looking for.
Best regards / Anna
0
Inger Marie
Top achievements
Rank 1
answered on 20 Jan 2015, 12:01 PM
"Then when the user click on this button the selected item will be null."
Is there a way to change the selected item from being set to null to some other value ? I have several scenarios where that would be great, mainly concerning non-nullable values such as enumerations (and numbers/int) and structs.
Is there a way to change the selected item from being set to null to some other value ? I have several scenarios where that would be great, mainly concerning non-nullable values such as enumerations (and numbers/int) and structs.
0
Hello Inger,
The behavior of the ClearButton could not be changed or modified. However, what we could suggest you in order to achieve the desired is to bind the SelectedIndex property of RadComboBox to the ViewModel. If the currently selected index is -1 (that value is set when the ClearButton is pressed) you could implement you're own custom logic and set it to some other value:
Hopes this helps.
Regards,
Nasko
Telerik
The behavior of the ClearButton could not be changed or modified. However, what we could suggest you in order to achieve the desired is to bind the SelectedIndex property of RadComboBox to the ViewModel. If the currently selected index is -1 (that value is set when the ClearButton is pressed) you could implement you're own custom logic and set it to some other value:
public
int
SelectedIndex
{
get
{
return
this
.selectedIndex;
}
set
{
if
(
this
.selectedIndex != value)
{
if
(value == -1)
{
//Implement your custom logic here. For example when the ClearButton is pressed the SelectedIndex will be set to 2
this
.selectedIndex = 2;
}
else
{
this
.selectedIndex = value;
}
this
.OnPropertyChanged(() =>
this
.SelectedIndex);
}
}
}
Hopes this helps.
Regards,
Nasko
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Carsten
Top achievements
Rank 1
Veteran
answered on 02 Jun 2020, 09:26 AM
works also with Visibility-Binding
ClearSelectionButtonVisibility="{Binding SelectedStringValue, Converter={StaticResource StringToVisibility}}"
nice