wpf - How can I sort a bound ListBox with custom sort logic? -
i'd sort view instead of in viewmodel.
every example i've seen uses sortdescription, it's not customizable.
the viewmodel can responsible data consumed view , presentation, model should not concerned display of data.
you bind view observablecollection on viewmodel, have. not saying how allow user sort, arguments sake assuming series of buttons, each button bound icommand on viewmodel, modify observablecollection change order.
this refresh view new order in observablecollection.
you still maintaining layers, , avoiding code behind , allowing sorting logic tested.
Comments
Post a Comment