You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[ ] Regression (a behavior that used to work and stopped working in a new release)
[X] Bug report <!-- Please search GitHub for a similar issue or PR before submitting -->
[ ] Feature request <!-- Please file a UserVoice request and include the link below https://wpdev.uservoice.com/forums/110705-universal-windows-platform/category/193402-uwp-community-toolkit -->
[ ] Sample app request
[ ] Documentation issue or request
[ ] Question of Support request => Please do not submit support request here, instead see https://github.com/Microsoft/UWPCommunityToolkit/blob/master/contributing.md#question
Current behavior
I'm using an AdvancedCollectionView bound to a ListView to display items sorted by a DateTime property. I noticed that an exception occured in the OnPropertyChanged of the bound items when live shaping was enabled (true passed as second parameter to AdvancedViewCollection). After further analysis I saw that the NullReferenceException was thrown inside method ItemOnPropertyChanged of AdvancedCollectionView. This line throws the Exception when no filter has been set: var filterResult = _filter(item);
So I changed my setup of the AVC from:
_acv = new AdvancedCollectionView(_timeEntries, true);
_acv.SortDescriptions.Add(new SortDescription("DateAndTime", SortDirection.Ascending));
to the following:
_acv = new AdvancedCollectionView(_timeEntries, true);
_acv.Filter = te => !string.IsNullOrWhiteSpace(((TimeEntry)te).Title);
_acv.SortDescriptions.Add(new SortDescription("DateAndTime", SortDirection.Ascending));
I added a dummy filter, that filters out items without a title (which never occurs anyway), just so that I don't run into the NullReferenceException.
Expected behavior
Live Shaping should work without a filter set.
Minimal reproduction of the problem with instructions
Initialise an AVC with live shaping enabled, don't setup a filter
AVC should consume an ObserverableCollection and bind the AVC to the ItemSource of a ListView.
Make sure the items of the collection implement INotifyPropertyChanged and you fire an event for property changes. Make use of the properties inside the ListView (data template). Edit a property to make the event fire. Exception should occur when OnPropertyChanged fires.
I think I see the issue. Looks like I missed this. 😞 I'll look into adding a test and fixing the functionality.
For now the workaround identified by @TheShihan will fix this issue. i.e. Adding a dummy filter like: _acv.Filter = x => true; when live shaping is enabled.
TheShihan
changed the title
AdvancedCollectionView: Exception thrown in ItemOnPropertyChanged when live shaping enable but no filter set
AdvancedCollectionView: Exception thrown in ItemOnPropertyChanged when live shaping enabled but no filter set
Dec 7, 2017
I'm submitting a...
Current behavior
I'm using an AdvancedCollectionView bound to a ListView to display items sorted by a DateTime property. I noticed that an exception occured in the
OnPropertyChanged
of the bound items when live shaping was enabled (true passed as second parameter toAdvancedViewCollection
). After further analysis I saw that theNullReferenceException
was thrown inside methodItemOnPropertyChanged
ofAdvancedCollectionView
. This line throws the Exception when no filter has been set:var filterResult = _filter(item);
So I changed my setup of the AVC from:
to the following:
I added a dummy filter, that filters out items without a title (which never occurs anyway), just so that I don't run into the NullReferenceException.
Expected behavior
Live Shaping should work without a filter set.
Minimal reproduction of the problem with instructions
Initialise an AVC with live shaping enabled, don't setup a filter
AVC should consume an ObserverableCollection and bind the AVC to the ItemSource of a ListView.
Make sure the items of the collection implement
INotifyPropertyChanged
and you fire an event for property changes. Make use of the properties inside the ListView (data template). Edit a property to make the event fire. Exception should occur when OnPropertyChanged fires.Environment
The text was updated successfully, but these errors were encountered: