I have a RadListView I am setting up to replace the standard Maui ListView.
One thing I need to do is set the Selected item in the ViewModel as part of a filter so filtered item is already selected. This seems to be an issue with doing this in the RadListView.
<telerik:RadListView x:Name="RadListView"
BackgroundColor="Transparent" VerticalOptions="Fill"
ItemsSource="{Binding SymbolItems}"
SelectionMode="Single" SelectionGesture="Tap" IsGroupHeaderSticky="True"
SelectedItem="{Binding SelectedSymbolItem, Mode=TwoWay}" >
I setup the SelectedItem to fire off the Notify (this uses Prism base class)
public SymbolItem SelectedSymbolItem
{
get => _selectedSymbolItem;
set => SetProperty(ref _selectedSymbolItem, value);
}
But when I set the SelectedItem I get an exception
Value cannot be null. (Parameter 'indexPath')
at ObjCRuntime.ThrowHelper.ThrowArgumentNullException(String argumentName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/ThrowHelper.cs:line 28
at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle(INativeObject self, String argumentName) in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:line 42
at TelerikUI.TKListView.SelectItem(NSIndexPath indexPath, Boolean animated, UICollectionViewScrollPosition scrollPosition)
at Telerik.Maui.Controls.Compatibility.DataControlsRenderer.iOS.ListViewRenderer.SelectItem(Object item)
at Telerik.Maui.Controls.Compatibility.DataControls.RadListView.OnSelectedItemAdded(Object item)
at Telerik.Maui.Controls.Compatibility.DataControls.RadListView.OnSelectedItemsCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Telerik.Maui.Controls.Compatibility.DataControls.ListView.SelectedItemsCollection.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index)
at System.Collections.ObjectModel.ObservableCollection`1[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InsertItem(Int32 index, Object item)
at Telerik.Maui.Controls.Compatibility.DataControls.ListView.SelectedItemsCollection.InsertItem(Int32 index, Object item)
at System.Collections.ObjectModel.Collection`1[[System.Object, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Add(Object item)
at Telerik.Maui.Controls.Compatibility.DataControls.RadListView.UpdateSelectedItem()
at Telerik.Maui.Controls.Compatibility.DataControls.RadListView.OnPropertyChanged(String propertyName)
The value being set is definitely not null.
Also I notice that the Setter seems to be getting invoked twice, so if I put a breakpoint my code goes in and executes the setter, and then seems like the framework does something and invokes it again which throws the exception.
Can SelectedItem in a RadListView be set be using the bound property? (like with any general TwoWay binding). If not how could this be achieved?