c# - Windows 8 XAML ListView Header not same size -
currently having issue header of listview larger listview items, header doesn't line properly. use margin on header hack fix it, surely there's proper way fix this?
<datatemplate x:key="headertemplate" > <grid height="36" background="#99999999" margin="0,0,5,0"> <grid.columndefinitions> <columndefinition width="3*"/> <columndefinition width="*"/> <columndefinition width="3*"/> <columndefinition width="*"/> </grid.columndefinitions> <textblock x:uid="name" textwrapping="wrap" horizontalalignment="left" text="project" grid.column="0" style="{staticresource bodytextblockstyle}" /> <textblock x:uid="qty" textwrapping="wrap" horizontalalignment="left" text="qty" grid.column="1" style="{staticresource bodytextblockstyle}" /> <textblock x:uid="subtotal" textwrapping="wrap" horizontalalignment="left" text="sub total" grid.column="2" style="{staticresource bodytextblockstyle}" /> <textblock x:uid="total" textwrapping="wrap" horizontalalignment="left" text="total" grid.column="3" style="{staticresource bodytextblockstyle}" /> </grid> </datatemplate> // ... <listview x:name="cartgridview" itemssource="{binding cartitmes}" headertemplate="{staticresource headertemplate}" grid.row="1" verticalalignment="stretch" width="auto" itemcontainerstyle="{staticresource simplelistviewitemstyle}"> <listview.itemtemplate> <datatemplate> <grid height="auto" margin="0"> <grid.columndefinitions> <columndefinition width="3*"/> <columndefinition width="*"/> <columndefinition width="3*"/> <columndefinition width="*"/> </grid.columndefinitions> <textblock grid.column="0" style="{staticresource bodytextblockstyle}" horizontalalignment="left" text="{binding name, mode=twoway}"/> <textblock grid.column="1" style="{staticresource bodytextblockstyle}" horizontalalignment="center" text="{binding qty, mode=twoway}"/> <textblock grid.column="2" style="{staticresource bodytextblockstyle}" horizontalalignment="left" text="{binding subtotal, mode=twoway}"/> <textblock grid.column="3" style="{staticresource bodytextblockstyle}" horizontalalignment="center" text="{binding total, mode=twoway}"/> </grid> </datatemplate> </listview.itemtemplate> </listview>
add following listview definition
<listview.itemcontainerstyle> <style targettype="listviewitem"> <setter property="horizontalcontentalignment" value="stretch" /> </style> </listview.itemcontainerstyle>
Comments
Post a Comment