when adding items to the collection bound to the datagrid ItemsSource, the empty template remains visible.
this was working with 11.1.0 version
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