We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Binding SelectedItems on Multiple selection throws exception

Thread ID:





132970 Oct 1,2017 11:07 PM UTC Dec 20,2018 12:14 PM UTC Xamarin.Forms 5
Tags: SfListView
Asked On October 1, 2017 11:07 PM UTC

I am using MVVM and trying to bind slecteditems twoway mode. If I bind selecteditems from Viewmodel to View by raising Property changed, It throws exception as below

  <sfListView:SfListView x:Name="listItems"   SelectedItems="{Binding SelectedItems, Mode=TwoWay}"                 
                           ItemsSource="{Binding Items}"  SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"             
                             SwipeOffset="250"  BackgroundColor="White" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand"
                                           ItemSpacing="1"  IsStickyHeader="False" IsStickyFooter="False"   
                   AllowSwiping="True" IsEnabled="True">

  private ObservableCollection<Database.Model.Item> selectedItems;

        public ObservableCollection<Database.Model.Item> SelectedItems
                return selectedItems;
                if (value != selectedItems && ListSelectionMode == SelectionMode.Multiple)
                    selectedItems = value;

10-02 00:55:08.832 I/MonoDroid(24942): System.NullReferenceException: Object reference not set to an instance of an object.
10-02 00:55:08.832 I/MonoDroid(24942):   at Syncfusion.ListView.XForms.SfListView.OnSelectionModeChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00015] in <eb04770f88c84a24bd134736ce89a543>:0 
10-02 00:55:08.832 I/MonoDroid(24942):   at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x00108] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:592 
10-02 00:55:08.832 I/MonoDroid(24942):   at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:386 
10-02 00:55:08.832 I/MonoDroid(24942):   at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x001f9] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:173 
10-02 00:55:08.832 I/MonoDroid(24942):   at Xamarin.Forms.BindingExpression.Apply (System.Boolean fromTarget) [0x0003e] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:55 
10-02 00:55:08.832 I/MonoDroid(24942):   at Xamarin.Forms.BindingExpression+BindingExpressionPart.<PropertyChanged>b__47_0 () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:539 
10-02 00:55:08.832 I/MonoDroid(24942):   at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <d278c06ad5684d6882c743a94a93ebc2>:0 
10-02 00:55:08.832 I/MonoDroid(24942):   at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <d278c06ad5684d6882c743a94a93ebc2>:0 
10-02 00:55:08.832 I/MonoDroid(24942):   at (wrapper dynamic-method) System.Object:69d2077b-b265-45f9-a8c2-7c7704266070 (intptr,intptr)

Dinesh Babu Yadav [Syncfusion]
Replied On October 2, 2017 10:44 AM UTC

Hi Emil,   
Sorry for the inconvenience caused.     
Based on the given information, we have checked the reported issue and a support incident has been created under your account to track the status of the issue. Please log on to our support website to check for further updates.          
Dinesh Babu Yadav 

Replied On April 23, 2018 04:08 PM UTC


Same issue today. Can we bind to SelectedItems?
Property SelectedItems has only getter. 
Syncfusion: this control is great! You doing well:) but can you provide usage of SelectedItems in MVVM manner?  


This code throw exception:

                    ItemsSource="{Binding Vendors}" SelectionMode="Multiple"
                    SelectedItems="{Binding SelectedVendors}"
                    VerticalOptions="Start" Orientation="Horizontal">

[0:] System.NullReferenceException: Object reference not set to an instance of an object.
  at Syncfusion.ListView.XForms.SelectionController.ProcessItemsSourceChanged (System.Object oldValue, System.Object newValue) [0x00040] in :0 
  at Syncfusion.ListView.XForms.SfListView.OnItemsSourceChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x0001d] in :0 

Rawoof Sharief Muthuja Sherif [Syncfusion]
Replied On April 24, 2018 03:51 PM UTC

Hi Damian, 
We have checked the reported query “Binding collection of items to SelectedItems property throws null reference exception” from our side. We would like to let you know that SelectedItems property uses ObservableCollection of type ‘object’. So you need to specify generic object instead of model class as like below. 
Code Example[C#]: 
        private ObservableCollection<object> selectedItems; 
        public ObservableCollection<object> SelectedItems 
                return selectedItems; 
                if (value != selectedItems && ListSelectionMode == SelectionMode.Multiple) 
                    selectedItems = value; 
Please let us know if you require further assistance. 

Paul Parkins
Replied On December 19, 2018 09:10 AM UTC

This same caveat has just caught me out too, and changing my bound SelectedItems property type to ObservableCollection<Object> as suggested did resolve my problem.
In my opinion this is not clear enough in the online documentation. Yes the example shows a collection of Object, but the text does not state that it HAS to be of Object. The implication is that through inheritance, any type of class (inherited from Object) could be used. It seems this is not the case, and so should be stated.

This documentation does give the example, but should be improved as it does not state you have to use Object.
This document doesn't even discuss SelectedItems enough to warrant adding in the caveat.

Also, did you realise SelectedItems is not even offered by Intellisense (am using VS2017)?


Jayaleshwari N [Syncfusion]
Replied On December 20, 2018 12:14 PM UTC

Hi Emil,  
We have checked reported query from our side. You can bind the selected items property in xaml page but intelligence will not work in xaml is because we have used private set to set the collection for SelectedItems in our source to avoid inner exception in output window.  
Regarding documentation: 
We have logged task to update the required details regarding SelectedItems type. We will update the UG documentation shortly in live.

Jayaleshwari N. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon