Unplanned
Last Updated: 18 May 2023 13:33 by ADMIN
Stefania
Created on: 24 Apr 2023 08:19
Category: DataGrid
Type: Bug Report
2
DataGrid: Exception when using AddSingleton approach in shell app
Null reference exception when using the AddSingleton approach in the shell app. 
1 comment
ADMIN
Lance | Manager Technical Support
Posted on: 18 May 2023 13:33

Hi Community,

If you've landed on this item, you can resolve the issue by using AddScoped (instead of AddSingleton or AddTransient).

For example:

public static MauiAppBuilder RegisterViews(this MauiAppBuilder mauiAppBuilder)
{
    // These may try to instantiate objects in the XAML too soon, before MauiApplication.Current is available
    // mauiAppBuilder.Services.AddSingleton<MyDataGridPage>();
    // mauiAppBuilder.Services.AddTransient<MyDataGridPage>();
    
    // Solution
    mauiAppBuilder.Services.AddScoped<MyDataGridPage>();

    return mauiAppBuilder;
}

Regards,
Lance | Manager Technical Support
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.