Is there a way to format/customize what the empty view looks like? Currently it just says "No data", I wasn't sure if it was possible to add a custom message/style.
Thank you!
1 Answer, 1 is accepted
0
Lance | Senior Manager Technical Support
Telerik team
answered on 04 Aug 2023, 05:49 PM
Hello Angelica,
This is not currently available as a .NET MAUI-layer capability because not all of the native platforms have the empty content feature.
If you're on Windows, which is appears to be from the screenshot, then you can use the .NET MAUI platform handler to access the native ListView control. Once you have a reference to the native control, you can customize the content through the EmptyContent property.
If you're not familiar with how to use handlers, here's a demo. Notice you need to subscribe to the .NET MAUI control's HandlerChanged event in order to know exactly when in the lifecycle you can set this up.
publicpartialclassMainPage : ContentPage
{
publicMainPage()
{
InitializeComponent();
NamesListView.HandlerChanged += NamesListView_HandlerChanged;
}
privatevoidNamesListView_HandlerChanged(object sender, EventArgs e)
{
if (NamesListView.Handler == null)
return;
var mauiListView = sender as Telerik.Maui.Controls.Compatibility.DataControls.RadListView;
#if WINDOWS// Get a reference to the native RadListView from Telerik UI for WinUI.// IMPORTANT: Be very careful with the namespaces because "RadListView" exists in both .NET MAUI and in WinUI 3if (mauiListView?.Handler?.PlatformView isTelerik.UI.Xaml.Controls.Data.RadListView windowsListView)
{
// IMPORTANT: the EmptyContent must be native WinUI content... not .NET MAUI content!windowsListView.EmptyContent = new Microsoft.UI.Xaml.Controls.TextBlock { Text = "Hello, there are no names available" };
}
#endif
}
}
Regards,
Lance | Manager Technical Support
Progress Telerik
A brand new .NET MAUI course was just added to the Virtual Classroom. The training course is developed to help you get started with the Telerik UI for .NET MAUI components and features. It aims to put you in the shoes of an engineer who adds new features to an existing application. You can check it out at https://learn.telerik.com
I get the work-around, but really, come on guys this is fundamental features that should have been noticed when testing with no results, and sure "No data" should at least be customisable. These are Controls for building into 'our' apps that should be totally configurable, this is why we buy them.
If work-arounds are provided, can we have the work-around for all platforms, since this is the nature of the controls? Otherwise we need to have the same battle for all of them.