How do I customize the display of column headers in my WPF Datagrid? -
i trying customize datagrid. want insert content above column headers. trying use controltemplate this. have xaml code below. problem <contentpresenter />
not outputting anything. when load page, after
textblock appears directly below before
textblock nothing in between. want display column headers in space.
<datagrid itemssource="{binding list}" autogeneratecolumns="true"> <datagrid.template> <controltemplate> <stackpanel orientation="vertical"> <textblock>before</textblock> <contentpresenter /> <!-- outputs nothing --> <textblock>after</textblock> <itemspresenter /> </stackpanel> </controltemplate> </datagrid.template> </datagrid>
how display column headers between before
textblock , after
textblock? list object bindinglist of generic class has couple of public properties.
i found answer. should use <datagridcolumnheaderspresenter />
instead of <contentpresenter />
. code works looks like:
<datagrid itemssource="{binding list}" autogeneratecolumns="true"> <datagrid.template> <controltemplate> <stackpanel orientation="vertical"> <textblock>before</textblock> <datagridcolumnheaderspresenter /> <textblock>after</textblock> <itemspresenter /> </stackpanel> </controltemplate> </datagrid.template> </datagrid>
Comments
Post a Comment