Application Crashed when I try to use a ListView, But button is fine

1 Answer 98 Views
General Discussions
Allen
Top achievements
Rank 1
Iron
Iron
Allen asked on 11 Jul 2022, 12:18 PM | edited on 11 Jul 2022, 12:45 PM

Hey Team,

I have a very strange question for you, I created a MAUI class library:  and then created a TestButton inherits from RadButton, 

like below

using Telerik.Maui.Controls;

namespace TelerikLib.Components
{
    public class NovaButton : RadButton
    {
    }
}

I also created a TestListView inherited from RadListView like below


<?xml version="1.0" encoding="utf-8" ?>
<telerik:RadListView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:telerik="http://schemas.telerik.com/2022/xaml/maui"
             xmlns:local="clr-namespace:TelerikLib.Components"
             x:Class="TelerikLib.Components.TestListView" ItemsSource="{Binding Source}">
    <telerik:RadListView.BindingContext>
        <local:ViewModel />
    </telerik:RadListView.BindingContext>
    <telerik:RadListView.ItemTemplate>
        <DataTemplate>
            <telerik:ListViewTemplateCell>
                <telerik:ListViewTemplateCell.View>
                    <Grid>
                        <Label Margin="10" Text="{Binding Name}" />
                    </Grid>
                </telerik:ListViewTemplateCell.View>
            </telerik:ListViewTemplateCell>
        </DataTemplate>
    </telerik:RadListView.ItemTemplate>
</telerik:RadListView>


Code behind:

using Telerik.XamarinForms.DataControls;

namespace TelerikLib.Components;

public partial class TestListView : RadListView
{
	public TestListView()
	{
		InitializeComponent();
	}
}

After that I created a MAUI Main Project, and added class library reference into Main Project.

1. When I only add custom TestButton into Main Page, it runs well.

2. When I added custom TestListView, application always crashed, when I added  .UseTelerik() method, then it runs well. 

May I know why some components need .UseTelerik(), but some are not? 

If I define custom components based on Telerik, should I have to add .UseTelerik() method into MAUIProgram?

 

Issue: based on Telerk.UI.for.MAUI Trial 1.0.1 + MAUI 6.0.312

 

Thanks

Allen

 

1 Answer, 1 is accepted

Sort by
1
Venelin
Telerik team
answered on 11 Jul 2022, 02:15 PM

Hello Allen,

The components need .UseTelerik() to be called because it registers the necessary handlers and styles which are used in Telerik .NET MAUI controls. Some controls appear to work without calling .UseTelerik(), however they may not be displayed properly due to missing fonts or styles.

Because of this, even if nothing seems wrong, you must always call .UseTelerik() when you use any of the Telerik .NET MAUI controls in your project.

Let me know if you have any additional questions.

Regards,
Venelin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
General Discussions
Asked by
Allen
Top achievements
Rank 1
Iron
Iron
Answers by
Venelin
Telerik team
Share this question
or