c# - windows phone listbox stretch Item template items with ItemPanel Orientation Horizontally aligned -


i creating listbox in windows phone application such items aligned horizontally. want if there 5 items should occupy space equally if there 2 items in collection there should aligned accordingly occupying totalwidth/2 space. how can achieve below code have written:

   <listbox x:name="carselector" itemssource="{binding listdata}"                       verticalalignment="center" horizontalalignment="stretch"                       scrollviewer.verticalscrollbarvisibility="disabled"                      background="white"                       itemcontainerstyle="{staticresource selectorcontainerstyle}"                       style="{staticresource lstbxselectorstyle}"                      >             <listbox.itemspanel>                 <itemspaneltemplate>                            <grid>                         <i:interaction.behaviors>                             <control:griditempanelbehavior />                         </i:interaction.behaviors>                     </grid>                 </itemspaneltemplate>             </listbox.itemspanel>             <listbox.itemtemplate>                 <datatemplate>                             <grid horizontalalignment="stretch"                              >                             <image  height="56"                             width="56"                             verticalalignment="center"                             horizontalalignment="center"                             source="{binding id}" />                             </grid>                 </datatemplate>             </listbox.itemtemplate>         </listbox> 

behavior:

protected override void onattached()         {             base.onattached();              associatedobject.layoutupdated += associatedobject_layoutupdated;         }          void associatedobject_layoutupdated(object sender, eventargs e)         {             grid griditempanel = associatedobject grid;              var childcount = griditempanel.children.count;              // add required number of column definitions             (int row = 0; row < childcount; row++)             {                 griditempanel.columndefinitions.add(new columndefinition() { width = new gridlength(1, gridunittype.star) });             }              // set column property each chid             (int = 0; < childcount; i++)             {                 var child = griditempanel.children[i] frameworkelement;                 grid.setcolumn(child, i);             }         } 


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -