wpf controls - WPF dataGrid super Header for multiple columns -
i want header multiple columns in wpf datagrid
. tried header template display header 1 column.
below xaml have tried:
<datagrid> <datagrid.columns> <datagridtextcolumn> <datagridtextcolumn.headertemplate> <datatemplate> <stackpanel> <textblock>column 1</textblock> <textblock>xyz</textblock> </stackpanel> </datatemplate> </datagridtextcolumn.headertemplate> </datagridtextcolumn> <datagridtextcolumn header="header" /> </datagrid.columns> </datagrid>
i attaching expected result screen shoot:
<grid width="auto"> <grid.rowdefinitions> <rowdefinition /> <rowdefinition /> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition /> <columndefinition /> <columndefinition /> </grid.columndefinitions> <toolkit:datagrid x:name="problemslist" minheight="205" maxheight="205" margin="3" verticalalignment="top" autogeneratecolumns="false" canuseraddrows="false" canuserdeleterows="false" canuserreordercolumns="false" canuserresizecolumns="true" canuserresizerows="false" columnheaderstyle="{staticresource gridcolumnheaderstyle}" horizontalscrollbarvisibility="visible" itemssource="{binding fisapcorrections}" mouseleftbuttonup="problemslist_mouseleftbuttonup" selectionmode="single" sorting="problemslist_sorting" verticalscrollbarvisibility="auto"> <toolkit:datagrid.columns> <toolkit:datagridtemplatecolumn minwidth="50" celltemplate="{staticresource rowselected}" header="select" /> <toolkit:datagridtextcolumn minwidth="88" binding="{binding studentname}" header="student name" isreadonly="true" /> <toolkit:datagridtextcolumn x:name="dgtcssn" minwidth="50" binding="{binding ssn}" header="ssn" isreadonly="true" /> <toolkit:datagridtextcolumn x:name="dgtcstunum" minwidth="50" binding="{binding stunum}" header="stunum" isreadonly="true" /> <toolkit:datagridtextcolumn minwidth="80" binding="{binding campus}" header="campus" isreadonly="true" /> <toolkit:datagridtextcolumn width="50" minwidth="50" binding="{binding badmodel, converter={staticresource toemptystringconverter}}" header="badmodel" headertemplate="{staticresource depmodelheadertemplate}" isreadonly="true" /> <toolkit:datagridtextcolumn width="72" minwidth="72" binding="{binding badpellenrollstatus, converter={staticresource toemptystringconverter}}" canuserreorder="false" header="badpellenrollstatus" headertemplate="{staticresource enrollstatusheadertemplate}" isreadonly="true" /> <toolkit:datagridtextcolumn width="75" minwidth="75" binding="{binding dupepell, converter={staticresource toemptystringconverter}}" header="dupepell" headertemplate="{staticresource dupstudentpellheadertemplate}" isreadonly="true" /> <toolkit:datagridtextcolumn width="80" minwidth="80" binding="{binding badtransactionid, converter={staticresource toemptystringconverter}}" header="badtransactionid" headertemplate="{staticresource invtransactionidheadertemplate}" isreadonly="true" /> <toolkit:datagridtextcolumn width="40" minwidth="40" binding="{binding hasnoisir, converter={staticresource toemptystringconverter}}" header="hasnoisir" headertemplate="{staticresource noisirheadertemplate}" isreadonly="true" /> <toolkit:datagridtextcolumn width="75" minwidth="75" binding="{binding gradwithseog, converter={staticresource toemptystringconverter}}" header="gradwithseog" headertemplate="{staticresource noteligxseogheadertemplate}" isreadonly="true" /> <toolkit:datagridtextcolumn width="100" minwidth="100" binding="{binding gradisdependent, converter={staticresource toemptystringconverter}}" header="gradisdependent" headertemplate="{staticresource gradwithdepmodelheadertemplate}" isreadonly="true" /> <toolkit:datagridtextcolumn width="60" minwidth="60" binding="{binding noclasses, converter={staticresource toemptystringconverter}}" header="noclasses" headertemplate="{staticresource noclassesheadertemplate}" isreadonly="true" /> <toolkit:datagridtextcolumn width="65" minwidth="65" binding="{binding ineligible}" header="ineligible" headertemplate="{staticresource schoolstatusheadertemplate}" isreadonly="true" /> <toolkit:datagridtemplatecolumn isreadonly="true"> <toolkit:datagridtemplatecolumn.celltemplate> <datatemplate> <textblock text="main header text" grid.columnspan="3" grid.row="0" grid.column="0"/> <textblock text="text 1" grid.column="0" grid.row="1"/> <textblock text="text 2" grid.column="1" grid.row="1"/> <textblock text="text 3" grid.column="2" grid.row="1"/> </datatemplate> </toolkit:datagridtemplatecolumn.celltemplate> <toolkit:datagridtemplatecolumn.headertemplate> <datatemplate> <textblock text="missing fisap summary part ii section f" textwrapping="wrap" width="200"/> </datatemplate> </toolkit:datagridtemplatecolumn.headertemplate> </toolkit:datagridtemplatecolumn> </toolkit:datagrid.columns> </toolkit:datagrid> <cmccontrols:waitingcontrol x:name="waitingcontrolongrid" horizontalalignment="center" verticalalignment="center" /> </grid>
i want add expected result in last of grid
try this;->
you need use 2 rows , 3 columns if want way screenshot depicts. in first row define textblock grid.columnsspan="3" take space 3 columns , in second row define each textblock in each different column:
<datagrid itemssource="{binding fisapcorrections,relativesource={relativesource ancestortype=window},updatesourcetrigger=propertychanged,mode=twoway}"> <datagrid.columns> <datagridtemplatecolumn width="200"> <datagridtemplatecolumn.celltemplate> <datatemplate> <grid> <grid.rowdefinitions> <rowdefinition height="150"/> <rowdefinition height="150"/> </grid.rowdefinitions> <grid.columndefinitions> <columndefinition width="70" /> <columndefinition width="70"/> <columndefinition width="70"/> </grid.columndefinitions> <textblock text="main header text" height="100" grid.columnspan="3" grid.row="0" grid.column="0"/> <textblock text="text 1" height="100" grid.column="0" grid.row="1"/> <textblock text="text 2" grid.column="1" grid.row="1"/> <textblock text="text 3" grid.column="2" grid.row="1"/> </grid> </datatemplate> </datagridtemplatecolumn.celltemplate> </datagridtemplatecolumn> </datagrid.columns> </datagrid>
Comments
Post a Comment