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

How to handle empty ItemsSource collection

3 Answers 18 Views
ListPicker
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Martin
Top achievements
Rank 1
Martin asked on 16 Oct 2012, 09:25 AM

I use RadListPicker in my app. It's used for selecting target location, user can define all locations in the list, but it could empty as well.

The problem is how to handle the situation when the list of locations is empty? Currently is shows empty box and when I click it, it gets highlighted and won't return back to unhighlighted state (i guess it waits for selection, but none can happen if there is no item in the list).

I'd like to show a message "location list is empty" when there is no location to show and also to prohibit the editing (this could be achieved using converter for the Enabled property I guess)

I tried using ItemTemplate for returning that empty message or even SummaryForSelectedItemsDelegate, but when there is no item in source list, it's never called.

 <telerikInput:RadListPicker Header="header" ItemsSource="{Binding Locations}" SelectedItem="{Binding EditedLocation, Mode=TwoWay}" />

3 Answers, 1 is accepted

Sort by
0
Deyan
Telerik team
answered on 18 Oct 2012, 11:50 AM
Hello Martin,

Thanks for writing.

RadListPicker is designed with the intention to allow the users to pick from a predefined set of values. Its concept implies that it should always have a source and selection unless the Multiselect  mode is activated.

In your scenario I can suggest you implement a mechanism that hides the List Picker when no location can be selected and displays a corresponding message or similar.

I hope this helps.

Kind regards,
Deyan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Martin
Top achievements
Rank 1
answered on 18 Oct 2012, 11:59 AM

Yes, that's what I though as a last resort behavior.

Anyway adding mechanism for showing "Empty list message" would be a great feature. There is already similar feature in DataBoundListBox.

0
Deyan
Telerik team
answered on 18 Oct 2012, 12:48 PM
Hello Martin,

Thanks for writing back.

There is already a mechanism for displaying empty content message: the NoSelectionContent property. This property, however, works only when the selection mode is set to be Multiselection. When the selection mode is set to be single we assume that there will always be a selected item from the source.

Greetings,
Deyan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ListPicker
Asked by
Martin
Top achievements
Rank 1
Answers by
Deyan
Telerik team
Martin
Top achievements
Rank 1
Share this question
or