Completed
Last Updated: 31 Jan 2024 07:55 by ADMIN
Release 6.7.0
Dan
Created on: 15 Nov 2023 20:54
Category: UI for .NET MAUI
Type: Bug Report
1
Programatically adding an item to RadComboBox.SelectedItems results in an ArgumentOutOfRangeException on iOS only when the ComboBox is hidden

When programatically trying to add an item to RadComboBox.SelectedItems (in multiple selection mode) similar to this answer, we get an ArgumentOutOfRangeException on iOS.  It works fine on Android.

https://www.telerik.com/forums/radcombobox-binding-selecteditem-not-work-when-selectionmode-is-multiple

The stack trace is strange:

[0:] {"@t":"2023-11-15T20:53:41.1123080Z","@mt":"Unhandled Exception","@l":"Fatal","@x":"System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.Generic.List`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].get_Item(Int32 index)
   at Telerik.Maui.RadWrapLayoutManager.ArrangeChildren(Rect bounds)
   at Microsoft.Maui.Controls.Layout.CrossPlatformArrange(Rect bounds)
   at Microsoft.Maui.Platform.MauiView.CrossPlatformArrange(Rect bounds)
   at Microsoft.Maui.Platform.MauiView.LayoutSubviews()
   at UIKit.UIApplication.UIApplicationMain(Int32 argc, String[] argv, IntPtr principalClassName, IntPtr delegateClassName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 58
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:line 94
   at TeamDynamix.Mobile.WorkManagement.Program.Main(String[] args) in C:\\git\\enterprise\\mobile-app\\TeamDynamix.Mobile.WorkManagement\\Platforms\\iOS\\Program.cs:lin
3 comments
ADMIN
Yana
Posted on: 14 Dec 2023 06:59

Hi Dan,

Thank you for the additional information, indeed, I've managed to reproduce the exception when the ComboBox is hidden.  I've updated the title to add the new details and changed the status of the bug report to "Unplanned".

Hopefully, we'll manage to quickly resolve it.  As you follow the item, you will receive an email notification as soon as there's any update on it.

I've updated your points for bringing this issue to our attention. I am sorry for any inconvenience caused.

Regards,
Yana
Progress Telerik

A brand new .NET MAUI course was just added to the Virtual Classroom. The training course is developed to help you get started with the Telerik UI for .NET MAUI components and features. It aims to put you in the shoes of an engineer who adds new features to an existing application. You can check it out at https://learn.telerik.com
Dan
Posted on: 12 Dec 2023 21:59

After a lot of trial and error, I figured out a way to reproduce the problem with your test app.

From the stacktrace, you can see the problem has to do with Telerik's layout code:

 at Telerik.Maui.RadWrapLayoutManager.ArrangeChildren(Rect bounds)

The problem happens when the RadComboBox is inside of a container that is invisible, and you try to add new items.

So to reproduce the problem with your Test app,  update the XAML to this.  Note how the containing Grid is marked as invisible.

<Grid>
  <Grid IsVisible="False">
  <telerik:RadComboBox ItemsSource="{Binding Items}"
                                SelectionMode="Multiple"
                                DisplayMemberPath="Name"
                                SelectedItems="{Binding SelectedItems}">
          <telerik:RadComboBox.BindingContext>
              <local:ViewModel/>
          </telerik:RadComboBox.BindingContext>
      </telerik:RadComboBox>
  </Grid>
</Grid>

 

Our project has the RadComboBox in a page similar to this.  It's inside of a Grid that's marked as invisible until a user clicks a button to reveal it.

 

ADMIN
Yana
Posted on: 22 Nov 2023 12:10

Hi Dan,

I've just tested the suggested in the forum thread approach with binding SelectedItems and adding items to it on iOS and it works properly on my side. I've attached my test app, can you download it and give it a try? Can you modify it, so that the issue to be reproduced and send it back for additional research?

I look forward to your reply.

Regards,
Yana
Progress Telerik

A brand new .NET MAUI course was just added to the Virtual Classroom. The training course is developed to help you get started with the Telerik UI for .NET MAUI components and features. It aims to put you in the shoes of an engineer who adds new features to an existing application. You can check it out at https://learn.telerik.com
Attached Files: