c# - XAML ListView auto width column -


i'm trying develop universal app personal use, running problem second column in listview doesn't align properly, have following xaml:

<listview          grid.row="1"          itemssource="{binding items, updatesourcetrigger=propertychanged}">         <listview.itemtemplate>             <datatemplate>                 <grid>                     <grid.columndefinitions>                         <columndefinition width="*" />                         <columndefinition width="auto" />                     </grid.columndefinitions>                     <grid.rowdefinitions>                         <rowdefinition height="*" />                         <rowdefinition height="1*" />                         <rowdefinition height="1*" />                     </grid.rowdefinitions>                     <image grid.column="0" grid.row="0" grid.rowspan="2" stretch="none" source="{binding image}" />                     <textblock grid.column="0" grid.row="2" text="{binding name}" horizontalalignment="center" />                     <image grid.column="1" grid.row="1" grid.rowspan="2" source="{staticresource highalchimage}" />                 </grid>             </datatemplate>         </listview.itemtemplate>     </listview> 

which results in following image:
enter image description here

however, want second image (the 1 that's same every time) align itself, preferably width of first column auto. possible?

the grid panel has such functionality built in. in order utilize should set sharedsizegroup on column definitions, , set attached grid.issharedsizescope on element parenting grids should share column sizes (listview choice in case).

<listview grid.row="1"           itemssource="{binding items, updatesourcetrigger=propertychanged}"           grid.issharedsizescope="true">     <listview.itemtemplate>         <datatemplate>             <grid>                 <grid.columndefinitions>                     <columndefinition width="auto" sharedsizegroup="column1" />                     <columndefinition width="auto" sharedsizegroup="column2" />                 </grid.columndefinitions>                 <grid.rowdefinitions>                     <rowdefinition height="*" />                     <rowdefinition height="1*" />                     <rowdefinition height="1*" />                 </grid.rowdefinitions>                 <image grid.column="0" grid.row="0" grid.rowspan="2" stretch="none" source="{binding image}" />                 <textblock grid.column="0" grid.row="2" text="{binding name}" horizontalalignment="center" />                 <image grid.column="1" grid.row="1" grid.rowspan="2" source="{staticresource highalchimage}" />             </grid>         </datatemplate>     </listview.itemtemplate> </listview> 

you might want take care while choosing values sharedsizegroup properties - preferably, should unique per visual tree.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -