c# - CollectionViewSource Violates MVVM -


i have mvvm app , in couple of vms use collectionviewsource.getdefaultview(datasource) initialize icollectionview , works perfectly. concern violating mvvm when using cvs in vms?

thank inputs

i prefer exposing collection in view model , creating collectionviewsource in xaml:

<window.resources>     <collectionviewsource x:key="collectionviewsource" source="{binding items}">         <i:interaction.behaviors>             <behaviors:myfilterlogic />         </i:interaction.behaviors>     </collectionviewsource> </window.resources>  <itemscontrol itemssource="{binding source={staticresource collectionviewsource}}" /> 

and behavior class:

public class myfilterlogic: behavior<collectionviewsource> {     protected override void onattached()     {         base.onattached();          associatedobject.filter += associatedobjectonfilter;     }      private void associatedobjectonfilter(object sender, filtereventargs filtereventargs)     {         // filter logic     } } 

some other experts don't mind exposing collectionview within view model: https://stackoverflow.com/a/979943/3351315


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -