c# - Column Alignment In Listbox -
is there better way align columns? when text changes 3 , 4 columns move on place. have tried setting width * , auto, nothing seems work.
<listbox height="auto" borderthickness="0" mousedoubleclick="onmousedoubleclick" itemssource="{binding path=results}" selecteditem="{binding path=entry, mode=twoway}" alternationcount="2"> <listbox.itemtemplate> <datatemplate> <grid> <grid.columndefinitions> <columndefinition minwidth="150"></columndefinition> <columndefinition minwidth="150"></columndefinition> <columndefinition minwidth="150"></columndefinition> <columndefinition minwidth="100"></columndefinition> </grid.columndefinitions> <textblock grid.column="0" fontfamily="sagoe ui" fontsize="14" text="{binding fullname}" padding="2" /> <textblock grid.column="1" fontfamily="sagoe ui" fontsize="14" text="{binding company}" padding="2" /> <textblock grid.column="2" fontfamily="sagoe ui" fontsize="14" text="{binding businessphone}" padding="2" /> <textblock grid.column="3" fontfamily="sagoe ui" fontsize="14" text="{binding emailaddress}" padding="2" > </textblock> </grid> </datatemplate> </listbox.itemtemplate> </listbox>
you can try setting grid.issharedsizescope on listbox , setting unique sharedsizegroup on every grid column. should align columns.
<listbox grid.issharedsizescope="true" height="auto" borderthickness="0" mousedoubleclick="onmousedoubleclick" itemssource="{binding path=results}" selecteditem="{binding path=entry, mode=twoway}" alternationcount="2"> <listbox.itemtemplate> <datatemplate> <grid> <grid.columndefinitions> <columndefinition sharedsizegroup="a"></columndefinition> <columndefinition sharedsizegroup="b"></columndefinition> <columndefinition sharedsizegroup="c"></columndefinition> <columndefinition sharedsizegroup="d"></columndefinition> </grid.columndefinitions> <textblock grid.column="0" fontfamily="sagoe ui" fontsize="14" text="{binding fullname}" padding="2" /> <textblock grid.column="1" fontfamily="sagoe ui" fontsize="14" text="{binding company}" padding="2" /> <textblock grid.column="2" fontfamily="sagoe ui" fontsize="14" text="{binding businessphone}" padding="2" /> <textblock grid.column="3" fontfamily="sagoe ui" fontsize="14" text="{binding emailaddress}" padding="2" > </textblock> </grid> </datatemplate> </listbox.itemtemplate> </listbox>
Comments
Post a Comment