Askcomp eugi-tech
Askcomp eugi-tech

Reputation: 83

ListView with grouping and sorting not refresh while INotifyPropertyChanged used

I have my own class which uses INotifyPropertyChanged correctly (Raising updates events), but when a property of type DateTime updated and called (View.Run) the listView not updating untill another property changing (not this property)

Now with the code:

Public Class EntryInfo
Implements INotifyPropertyChanged
 ReadOnly Property DateAccessed As Date
    Get
        .......
        Return _Access
    End Get
End Property
Readonly Property Property1 as object
 Get
        .......
        Return _Property1 
    End Get
End Property

Friend Sub NotifyPropertyChanged(ByVal info As String)
    RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(info))
    RaiseEvent ApropertyHasChanged()
End Sub

Then when I need to Change the "DateAccessProperty" I use this code:

 Friend Sub SetAccessTime(Dt As Date)
    _Access = Dt
    NotifyPropertyChanged("DateAccessed")
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''' After this I have a ListView named "LV1"

Dim Coll as new observableCollection(Of EntryInfo) 
....... filing "Coll" with items (EntryInfo)
Lv1.ItemsSource =Coll

Then I do the following:

  1. Do some sort and group operations.
  2. Changing "DateAccessed" value. so that the "ApropertyHasChanged" event fired and at this point I used the following code

    Private Sub RefreshViewNow()

    Dim _view As ListCollectionView = TryCast(CollectionViewSource.GetDefaultView(LV1.ItemsSource), ListCollectionView)
    
    If _view IsNot Nothing Then _view.Refresh()
    
    '\\\ Items.Refresh()
    

    End Sub

But _view not refreshed.

But if the property "Property1" changed the _View refreshed.

Any help?

Upvotes: 1

Views: 405

Answers (1)

Askcomp eugi-tech
Askcomp eugi-tech

Reputation: 83

The solution is by set the following "_view" properties:

_view.IsLiveFiltering = True _view.IsLiveGrouping = True _view.IsLiveSorting = True

or at least one of them if you want one of them only to be activated.

Upvotes: 1

Related Questions