How can define a custom ListView which is inherited from RadListView

1 Answer 421 Views
ListView
Allen
Top achievements
Rank 1
Iron
Iron
Allen asked on 21 Jul 2022, 09:10 AM

Hey Team,

I want to create a Custom ListView which is inherited from RadListView Directly. Is there a way to Implement it? 

I did a way but failed:

<?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"
                     x:Class="Text.ListViews.TelerikListView">
</telerik:RadListView>
using Telerik.UI.Xaml.Controls.Data;

namespace Text.ListViews
{
    public partial class TelerikListView : RadListView
    {
        public TelerikListView()
        {
            InitializeComponent();
        }
    }
}

It gives me a error:

 

Thanks

Allen

1 Answer, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 21 Jul 2022, 01:40 PM

Hi Allen,

You can create a custom control in this way:

Create a class for example MyCustomListView which inherits from RadListView:

 

public class MyCustomListView : RadListView 
    { 
    }

 

then consume the custom control in your xaml like this:

<ContentPage x:Class="MyAppName.MainPage"
             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:MyAppName">

    <local:MyCustomListView>
        
    </local:MyCustomListView>
</ContentPage>

 

Regards,
Didi
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/.

Allen
Top achievements
Rank 1
Iron
Iron
commented on 22 Jul 2022, 09:53 AM | edited

I did as what you said, But I found a issue, If we add using reference for RadListView, which one should we use?  

 

and May I know what's the different using "Telerik.UI.Xaml.Controls.Data" with "Telerik.XamarinForms.DataControls"?

Current Telerik we are using 1.0.1 + MAUI 312

Thanks

Allen

Didi
Telerik team
commented on 22 Jul 2022, 10:37 AM

As you are using Telerik MAUI 1.0.1 version - the namespace you have to use is Telerik.XamarinForms.DataControls

The namespace Telerik.UI.Xaml.Controls.Data is for the native WinUI ListView control.
Allen
Top achievements
Rank 1
Iron
Iron
commented on 22 Jul 2022, 10:41 AM

Thanks for your clarify!
Tags
ListView
Asked by
Allen
Top achievements
Rank 1
Iron
Iron
Answers by
Didi
Telerik team
Share this question
or