c# - Variable-Sized GridViewItem in GridView -


in gridview (windows 8 app), use following item template show items :

<datatemplate x:key="projecttemplate">     <grid width="500" background="midnightblue">         <grid.rowdefinitions>             <rowdefinition height="auto"/>             <rowdefinition height="auto"/>             <rowdefinition height="auto"/>         </grid.rowdefinitions>         <textblock grid.row="0" text="{binding name}" margin="20, 10" style="{staticresource subheadertextstyle}" textwrapping="wrap" foreground="whitesmoke"/>         <stackpanel grid.row="1" orientation="horizontal" margin="20, 10, 10, 10" background="midnightblue">             <textblock text="last modified :" style="{staticresource titletextstyle}" foreground="whitesmoke"/>             <textblock text="{binding lastmodified}" margin="5, 0, 0, 0" style="{staticresource titletextstyle}" foreground="whitesmoke"/>         </stackpanel>         <textblock grid.row="2" text="{binding videopath}" margin="20, 10, 10, 10" style="{staticresource titletextstyle}" textwrapping="wrap" foreground="whitesmoke"/>     </grid> </datatemplate> 

so, mainly, grid 3 rows showing data binded name, lastmodified , videopath properties of project item gridview deals with. items retrieved correctly, binding ok, problem more matter of... design.

here's example :

enter image description here

if notice, first 2 items, seem ok - have name, lastmodified date , videopath shown. third item, on other hand, has longer name shown in textblock textwrapping=true, , videopath omitted when shown. third textblock videopath has textwrapping set.

is there way enlarge grid each item individual according needs show full content? modifications need make template?

edit

i didn't want set height explicitly, because in case, gridviewitems (in the textblocks' text short enough 1 row), larger , have... empty areas (sorry bad explanation, can't find words put better)...

altough searched lot variable-sized items, , found many... complicated solutions, came across easy one.

winrt xaml toolkit has nice wrappanel did job in case. instead of grid, in template, used wrappanel, , in gridview's itempaneltemplate :

<gridview.itemspanel>     <itemspaneltemplate>         <toolkit:wrappanel orientation="vertical"/>      </itemspaneltemplate> </gridview.itemspanel> 

the result looks : enter image description here


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -