MAUI: Enhanced listview for iOS plaform

Sreejith Sreenivasan 586 Reputation points

I have an enhanced listview (Helpers) which is working fine on Xamarin Forms project. But when I migrate it to MAUI my app is breaking with below exception.

System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Maui.Controls.Compatibility.Platform.iOS.CellTableViewCell.GetNativeCell(UITableView , Cell , Boolean , String ) at Microsoft.Maui.Controls.Compatibility.Platform.iOS.ListViewRenderer.ListViewDataSource.GetCell(UITableView , NSIndexPath ) at UIKit.UIApplication.UIApplicationMain(Int32 , String[] , IntPtr , IntPtr ) at UIKit.UIApplication.Main(String[] , Type , Type ) at MyProject.Program.Main(String[] args) in /Users/MyCompany/Projects/MyProject-maui/MyProject/Platforms/iOS/Program.cs:line 13


Screen Shot 2023-11-15 at 5.27.28 AM

My Code:


public class EnhancedListView : ListView
    public EnhancedListView()
    public void ForceNativeTableUpdate()
    public event Action ViewCellSizeChangedEvent;

iOS Platform

class EnhancedListViewRenderer : ListViewRenderer
    protected override void OnElementChanged(ElementChangedEventArgs<ListView> e)
        if (e.NewElement is EnhancedListView enhancedListView)
            enhancedListView.ViewCellSizeChangedEvent += UpdateTableView;
        if(Control != null)
            Control.SectionHeaderTopPadding = new nfloat(0);
    private void UpdateTableView()
        if (!(Control is UITableView tv)) return;

Android part is working fine without any enhanced renderers. It is expanding and collapsing when data is visible on the UI.

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,126 questions
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 24,356 Reputation points Microsoft Vendor


    Thanks for your feedback.

    After testing, your code will work fine on iOS. Therefore, the cause of this issue is more likely to be an issue with the development tool.

    In addition, using the Renderer in MAUI should comply with the specifications in this document.

    Best Regards,

    Alec Liu.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful