Unplanned
Last Updated: 22 May 2026 16:53 by ADMIN
Cameron
Created on: 22 May 2026 16:31
Category: DataGrid
Type: Bug Report
0
DataGrid: Empty template remains visible when adding items to the collection with 12.0.0 version and above

when adding items to the collection bound to the datagrid ItemsSource, the empty template remains visible.

this was working with 11.1.0 version

1 comment
ADMIN
Didi
Posted on: 22 May 2026 16:53

Workaround:

set the empty template to the resource when clear the items and set it to null when adding items:

<ContentPage.Resources>
    <DataTemplate x:Key="EmptyContentTemplate">
        <Label Margin="10" TextColor="Red" HorizontalOptions="Center" Text="No data to display" />
    </DataTemplate>
</ContentPage.Resources>

<Grid RowDefinitions="Auto, *">
    <telerik:RadUniformGrid>
        <telerik:RadTemplatedButton Content="Clear temsSource" Clicked="OnCounterClicked" />
        <telerik:RadTemplatedButton Content="Add Item" Clicked="OnAddClicked"/>
    </telerik:RadUniformGrid>
    <telerik:RadDataGrid Grid.Row="2"
                            x:Name="dataGrid"
                            ItemsSource="{Binding Collection}"
                            EmptyContentTemplate="{StaticResource EmptyContentTemplate}"
                            EmptyContentDisplayMode="ItemsSourceNullOrEmpty" />
</Grid>
public partial class MainPage : ContentPage
{
    int count = 0;
    MainViewModel vm;
    public MainPage()
    {
        InitializeComponent();
        this.vm = new MainViewModel();
        this.BindingContext = this.vm;
    }
    private void OnCounterClicked(object? sender, EventArgs e)
    {
        this.vm.Collection.Clear();
         this.dataGrid.EmptyContentTemplate = this.Resources["EmptyContentTemplate"] as DataTemplate;
    }

    private void OnAddClicked(object sender, EventArgs e)
    {
        this.vm.Collection.Add(new VMData { Value = "rwerwerwer" });
        this.dataGrid.EmptyContentTemplate = null;
    }
}

Regards,
Didi
Progress Telerik