Completed
Last Updated: 13 Mar 2024 08:17 by ADMIN
Release 6.8.0
Eric
Created on: 14 Feb 2024 15:27
Category: UI for .NET MAUI
Type: Bug Report
0
DataGrid: [WinUI] ArgumentOutOfRange exception when column are added manually and IWindowCreator approach is used

We have discovered an error when you implement IWindowCreator and create custom window and connect viewmodel via AddSingleton approach

This is the stack-trace:

at System.ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessException()

at System.Collections.Generic.List`1.get_Item(Int32 index)

at Telerik.Maui.RadScreen.GetPixelScale(DipScaleType dipScaleType)

at Telerik.Maui.Controls.RadScreenControls.GetPixelScale(VisualElement visualElement, DipScaleType dipScaleType)

at Telerik.Maui.Controls.SkiaSharp.SkiaPainter.GetPixelScale()

at Telerik.Maui.Controls.SkiaSharp.SkiaPainter..ctor(SkiaPainterCacheSettings cacheSettings)

at Telerik.Maui.Controls.Compatibility.DataGrid.MasterArranger..ctor(RadDataGrid dataGrid, NonLayoutPanel root, SkLayoutSlotProvider skLayoutSlotProvider)

at Telerik.Maui.Controls.Compatibility.DataGrid.RadDataGrid.InitArrangers()

at Telerik.Maui.Controls.Compatibility.DataGrid.RadDataGrid.Telerik.Maui.Controls.Compatibility.DataGrid.IGridView.AttachColumn(DataGridColumn column)

at Telerik.Maui.Controls.Compatibility.DataGrid.GridModel.AttachColumn(DataGridColumn column)

at Telerik.Maui.Controls.Compatibility.DataGrid.DataGridColumnCollection.AttachColumn(DataGridColumn column)

at Telerik.Maui.Controls.Compatibility.DataGrid.DataGridColumnCollection.InsertItem(Int32 index, DataGridColumn item)

at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)

at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)

1 comment
ADMIN
Didi
Posted on: 14 Feb 2024 15:47

Workaround:

Subscribe to the Page.Loaded event and define the columns in the event:

private void ContentPage_Loaded(object sender, EventArgs e)
    {
        this.dataGrid.Columns.Add(new DataGridTextColumn()
        {
            PropertyName = "Name",
        });
        this.dataGrid.Columns.Add(new DataGridTextColumn()
        {
            PropertyName = "Address",
        });
        this.dataGrid.Columns.Add(new DataGridDateColumn()
        {
            PropertyName = "Date",
        });
    }

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