wpf - Squaring ListView items using a DataTemplate -


i trying style listview in project, , i'd items squared.
below current state based on answers found online.

my listview:

<listview scrollviewer.horizontalscrollbarvisibility="disabled"               scrollviewer.verticalscrollbarvisibility="hidden" grid.row="1"               background="transparent" itemssource="{binding ribbonitemlist}" itemtemplate="{staticresource ribbonpageslistitemtemplate}" /> 

and here's try @ squaring listviews itemtemplate:

<datatemplate x:key="ribbonpageslistitemtemplate" datatype="x:type apppage">     <grid width="auto" height="{binding relativesource={relativesource self}, path=actualwidth}">         <image height="25" width="25" source="{binding path=imgsrc}" />     </grid> </datatemplate> 

however, above not work, , can't find explanation or suitable solution.
how make work?

if want whole item container (i.e. element highlighted upon hovering or selection) square, rather trying accomplish itemtemplate, used define appearance of item inside container, should style item container using itemcontainerstyle property:

<listview scrollviewer.horizontalscrollbarvisibility="disabled"           scrollviewer.verticalscrollbarvisibility="hidden"            background="transparent"           itemssource="{binding ribbonitemlist}"           itemtemplate="{staticresource ribbonpageslistitemtemplate}">     <listview.itemcontainerstyle>         <style targettype="{x:type listviewitem}">             <setter property="width"                     value="{binding actualheight, relativesource={relativesource self}}" />         </style>     </listview.itemcontainerstyle> </listview> 

you can remove grid item template.


Comments

Popular posts from this blog

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

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

ruby on rails - Seeing duplicate requests handled with Unicorn -