grouping - WPF ItemsControl ItemTemplate border with GroupStyle -
this first time i've posted pic, turns out (a picture worth thousand words, , don't want type thousand words). but, image below i'm trying accomplish.
i have collection of objects i'm needing grouped property "group". i'm using collectionviewsource bound data source doing grouping me.
i'm using itemscontrol control (but use control) display information. i'm able group information property i'd able surround entire group border. i'm not wanting surround each item in group entire group.
how accomplish picture below border around entire group?
something should trick. use group style. want customize more, should able general idea snippet.
the main thing know binding groupitem. there 3 properties on groupitem. name (of group), itemcount (how many items in grouping) , items themselves.
<controltemplate targettype="{x:type groupitem}"> <border borderbrush="black" borderthickness="1" margin="5"> <stackpanel> <textblock text="{binding name}"/> <border borderbrush="black" borderthickness="1" margin="0,0,0,0"> <itemspresenter /> </border> </stackpanel> </border> </controltemplate>
edit: when group collection of items, source not collection of items, collection of groupitems, wich contains items collection belong group. why x:type
groupitem. no binding required here, other properties of groupitem wish display.
you should put in <itemcontrol>
xaml so:
<itemscontrol> <itemscontrol.groupstyle> <!-------------- style above goes here ---------------> <itemscontrol.groupstyle/> <itemscontrol/>
here article on grouping in wpf out.
Comments
Post a Comment