Thursday, 15 July 2010

windows 8 - Listview selection display with no padding and no checkmark -



windows 8 - Listview selection display with no padding and no checkmark -

i have xaml display listview in c++/cx code. listview used selection menu.

<listview x:name="itemslistview" itemssource="{binding source={staticresource menudatasourcecvs}}" horizontalalignment="stretch" width="230" margin="0,45,0,0" verticalalignment="top" grid.row="1" selectionchanged="itemslistview_selectionchanged" selectionmode="single" horizontalcontentalignment="stretch" verticalcontentalignment="stretch" fontfamily="global user interface"> <listview.itemtemplate> <datatemplate> <stackpanel orientation="horizontal" height="40" width="230"> <textblock text="{binding name}" margin="10,5" width="150" height="30" horizontalalignment="stretch" verticalalignment="stretch"/> <border height="30" width="30" margin="5"> <image source="{binding imagesrc}" stretch="fill"/> </border> </stackpanel> </datatemplate> </listview.itemtemplate> </listview>

as can see in figure bellow selection not occupy column , displays checkmark when selected.

is there way eliminate padding , checkmark?

you need open view in blend, right click list , select "edit additional templates"/"edit generated item container (itemcontainerstyle)"/"edit copy". can edit style listviewitem generated listview when populated items. in "states" tab on left can see states used listviewitem. when select 1 of them - design surface shows listviewitem looks in state , switches recording mode can define property values of various element properties of template. can see elements affected visual state animations , either modify these animations or remove elements themselves. if remove element in blend - related visual state animations deleted automatically, in case can see in selectionstates visualstatesgroup selected state changes selectionbackground element's opacity 1. can either modify target opacity value in states modify desired value or remove selectionbackground element selecting in "objects , timeline" panel (it remove template states , remove animations impact it). may want remove hintglyphborder, selectingglyph, selectedcheckmarkouter.

to remove padding - create sure disable recording state either clicking tiny reddish recording button or switching displayed state in "states" tab "base", select contentborder , alter margin in "properties" tab 0,0,0,0 , same selectedborder.

here's annotated screenshot blend:

listview windows-8 windows-runtime winrt-xaml c++-cx

No comments:

Post a Comment