C# Windows Phone 8.1: ListView selected state not working as expected -
i have windows phone 8.1 (wp 8.1) listview
. itemssource
of listview
observablecollection<item>
, selectedvalue
binds property selecteditem
. see code snipped below.
<listview selectedvalue="{binding selecteditem, mode=twoway}" itemssource="{binding items}"> <listview.itemcontainerstyle> <style targettype="listviewitem"> <setter property="horizontalcontentalignment" value="stretch" /> <setter property="foreground" value="#777" /> <setter property="template"> <setter.value> <controltemplate targettype="listviewitem"> <grid> <visualstatemanager.visualstategroups> <visualstategroup x:name="commonstates"> <visualstate x:name="normal"/> </visualstategroup> <visualstategroup x:name="selectionstates"> <visualstate x:name="unselected"> <storyboard> <coloranimation duration="0" storyboard.targetname="myback" storyboard.targetproperty="(border.background).(solidcolorbrush.color)" to="transparent"/> </storyboard> </visualstate> <visualstate x:name="selected"> <storyboard> <coloranimation duration="0" storyboard.targetname="myback" storyboard.targetproperty="(border.background).(solidcolorbrush.color)" to="#ff5b318f"/> </storyboard> </visualstate> <visualstate x:name="selectedunfocused"> <storyboard> <coloranimation duration="0" storyboard.targetname="myback" storyboard.targetproperty="(border.background).(solidcolorbrush.color)" to="#ff5b318f"/> </storyboard> </visualstate> </visualstategroup> </visualstatemanager.visualstategroups> <border x:name="myback" background="transparent"> <contentpresenter content="{templatebinding content}" contenttemplate="{templatebinding contenttemplate}"/> </border> </grid> </controltemplate> </setter.value> </setter> </style> </listview.itemcontainerstyle> <listview.itemtemplate> <datatemplate> <border margin="15,0,0,0" borderthickness="0,0,0,1" borderbrush="#979797"> <grid margin="-15,0,0,0" horizontalalignment="stretch" verticalalignment="stretch"> <textblock padding="15" text="{binding description}" fontfamily="ms-appx:/fonts/lato-regular.ttf#lato" foreground="#777" fontsize="18" /> </grid> </border> </datatemplate> </listview.itemtemplate> </listview>
the selectedvalue
binding working, background of (initial) selected item not change. changes after select item. have tried different visualstates
without result.
why background not set on selectedvalue
before select item?
thanks in advance,
michael
Comments
Post a Comment