c - UWP - Refreshing listview and CollectionViewSource -


i have created chatmessagegroup , chatmessagegroupcollection , listview itemssource set collectionviewsource:

<listview x:name="chatmessagelv" itemssource="{binding selectedchat.chatmessagegroupcollection.cvs.view}" itemtemplateselector="{staticresource chatmessagedatatemplateselector}"> 


public class chatmessagegroup : igrouping<datetime, chatmessage>, inotifycollectionchanged     {         private observablecollection<chatmessage> _chatmessages;         public datetime key { get; set; }          public observablecollection<chatmessage> chatmessages         {             { return _chatmessages; }             set             {                 if (_chatmessages != null)                     _chatmessages.collectionchanged -= collectionchanged;                  _chatmessages = value;                 _chatmessages.collectionchanged += collectionchanged;             }         }           public chatmessagegroup()         {             chatmessages = new observablecollection<chatmessage>();         }          public ienumerator<chatmessage> getenumerator()         {             return chatmessages.getenumerator();         }          ienumerator ienumerable.getenumerator()         {             return getenumerator();         }          public event notifycollectionchangedeventhandler collectionchanged;     }    public class chatmessagegroupcollection : ienumerable<chatmessagegroup>     {         private readonly observablecollection<chatmessagegroup> _groups;          public observablecollection<chatmessage> source { get; set; }         public collectionviewsource cvs { get; set; }          public chatmessagegroupcollection(observablecollection<chatmessage> messages)         {             source = messages;             messages.collectionchanged += messages_collectionchanged;              var groups = messages                 .groupby(getgroupkey)                 .select(x => new chatmessagegroup()                 {                     key = x.key,                     chatmessages = x.orderby(getgroupkey).toobservableordefault()                 })                 .orderby(x => x.key);              _groups = new observablecollection<chatmessagegroup>(groups);             cvs = new collectionviewsource() { issourcegrouped = true, source = _groups };         } ... 

everything works fine in here except changes inside group collection:

_groups.add(new chatmessagegroup()); -> line reflect changes in listview 

but if this: _groups[0].chatmessages.add(new chatmessage()) doesn't work though chatmessagegroup implementing inotifycollectionchanged , raised every time chatmessages observablecollection changed. workaround update chatmessages , remove group _groups , add again it's not solution. refresh() on collectionviewsource not available in uwp. there other solutions?

whilst doesn't technically qualify answer question think might qualify architectural answer.

the way make grouped list view update based on underlying collection changing in wpf simple setting islivegroupingrequested true on collectionviewsource instance declared in xaml.

as i've been working way through uwp (after decade of wpf) i've come conclusion microsoft suggesting through omission isn't right approach problem uwp. going lengths of implementing feature construed missing point somewhat.

in particular situation i've decided change approach entirely , implement rendering multiple instance of listviews opposed forcing old paradigm onto new platform.

the result of made me arrive @ solution improved ux boot.

food thought ...


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -