Last Updated: 17 Mar 2023 13:04 by Jason
Created on: 18 Jul 2022 12:35
Category: ListView
Type: Feature Request
ListView: Provide the option to set custom empty template

An example with CollectionView:

<CollectionView ItemsSource="{Binding EmptyMonkeys}"
                EmptyView="No items to display" />

Posted on: 17 Mar 2023 13:04

Thanks, Didi,

I understand that there are workarounds available. For that matter, I could build all the functionality of your ListView control myself if I wanted to. The point of my comment is that if I'm going to spend $1000 or more on a UI framework, I expect features, not workarounds. Microsoft's built-in CollectionView has the EmptyView option already. It can handle the empty-list state with as little as one line of XAML. I would expect a commercial control to have at least feature parity with what you can get for free. As it stands, your suggested workaround costs around 20 lines of C# plus the required XAML. I'm unimpressed. If I find similar holes in other controls, I won't be buying.

Posted on: 17 Mar 2023 05:37

Hi Jason,

The ListView does not have an empty template, this is why we have this feature request logged.

However there is an easy way to achieve an empty template:

- When your items source is empty, show the label.
- When the collection is not empty, hide the label.

    <Label IsVisible="{Binding IsListEmpty}" />
    <telerikDataControls:RadListView ItemsSource="{Binding MyItems}"/>

There are many ways to check if the list is empty, 

1. Subscribe to ListView.PropertyChnaged and if e.PropertyName == "ItemsSource" then implement a custom logic to display the label. 

2. another option is to use the CollectionChanged event. Here's an example:

public class ViewModel : NotifyPropertyChangedBase
    private bool isListEmpty;
    public ViewModel()
        MyItems.CollectionChanged += MyItems_CollectionChanged;
    private void MyItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        IsListEmpty = MyItems.Count == 0;
    public ObservableCollection<string> MyItems { get; set; } = new ObservableCollection<string>();
    public bool IsListEmpty
        get => isListEmpty;
            if (isListEmpty == value)
            isListEmpty = value;

Progress Telerik

Posted on: 16 Mar 2023 20:46
I'm testing your UI framework, and the lack of handling for an empty list seems like a huge hole. Am I missing something?