xamarin/Xamarin.Forms
ListView Item Selected changing, always looks up the index
Open
#5,541 opened on Mar 13, 2019
a/listviewe/4 :clock4:help wantedinactivet/bug :bug:up-for-grabs
Repository metrics
- Stars
- (5,644 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
Description
When you click on a row item in a ListView, it will lookup the index from the item source. The index is already known when the selection happens. Looking the index back up is a performance hit. Stack Trace:
at gMusic.ViewModels.GroupedList`1[T].IndexOf (System.Object value) [0x00000] in /Users/clancey/Projects/LiveStream/gMusic/gMusic/ViewModels/SimpleDatabaseSource.cs:145
at Xamarin.Forms.ListProxy.IndexOf (System.Object item) [0x00008] in D:\a\1\s\Xamarin.Forms.Core\ListProxy.cs:87
at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].GetGlobalIndexOfItem (System.Object item) [0x00008] in D:\a\1\s\Xamarin.Forms.Core\TemplatedItemsList.cs:388
at Xamarin.Forms.Internals.TemplatedItemsList`2[TView,TItem].GetGlobalIndexOfItem (System.Object item) [0x0003d] in D:\a\1\s\Xamarin.Forms.Core\TemplatedItemsList.cs:397
at Xamarin.Forms.ListView.OnSelectedItemChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\ListView.cs:601
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:624
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x00179] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:422
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:367
at Xamarin.Forms.ListView.NotifyRowTapped (System.Int32 groupIndex, System.Int32 inGroupIndex, Xamarin.Forms.Cell cell) [0x0004c] in D:\a\1\s\Xamarin.Forms.Core\ListView.cs:441
Steps to Reproduce
Expected Behavior
The IndexOf would never be called.
Actual Behavior
IndexOf is called on selection