c# - change the foreground Color of a TextBlock when Hover in a universal app -


i have listview,in want assign style when hover on each listviewitem style:details.xaml:

<listview x:name="listmee">      <listview.itemcontainerstyle>        <style targettype="listviewitem">          <setter property="template">          <setter.value>          <controltemplate targettype="listviewitem">            <grid>                     <visualstatemanager.visualstategroups>                  <visualstategroup x:name="commonstates">                     <visualstate x:name="normal"/>                 <visualstate x:name="pointerover">                   <storyboard>                       <coloranimation duration="0" to="#d9d7ec" storyboard.targetproperty="(rectangle.fill).(solidcolorbrush.color)" storyboard.targetname="listitem1" />                                                                                                                              <coloranimation duration="0" to="black" storyboard.targetproperty="(textblock.foreground).(solidcolorbrush.color)" storyboard.targetname="content1" />                  </storyboard>                 </visualstate>                    <visualstate x:name="pressed">                    <storyboard>                                                                                                                                                                                                                      <coloranimation duration="0" to="#d9d7ec" storyboard.targetproperty="(rectangle.fill).(solidcolorbrush.color)" storyboard.targetname="listitem1" />                            <coloranimation duration="0" to="black" storyboard.targetproperty="(textblock.foreground).(solidcolorbrush.color)" storyboard.targetname="content1" />                                                                                                                                       </storyboard>                                                                    </visualstate>                                                                </visualstategroup>                                                            </visualstatemanager.visualstategroups>             <grid>   <rectangle x:name="listitem1" stroke="transparent" fill="transparent"  />    <contentpresenter x:name="content1"/>            </grid>         </grid>      </controltemplate>     </setter.value>   </setter> </style> </listview.itemcontainerstyle> <listview.itemtemplate> <datatemplate>      <stackpanel orientation="horizontal">              <stackpanel  horizontalalignment="left"  orientation="horizontal">                      <textblock  x:name="day" text="{binding path=nom_jour}"   foreground="gray" ></textblock>              </stackpanel>              <stackpanel  horizontalalignment="right"  orientation="horizontal">                                                                             <textblock x:name="hour_deb" text="{binding path=deb_jour}" foreground="gray"></textblock>              </stackpanel>     </stackpanel>  </datatemplate> </listview.itemtemplate > </listview> 

the problem code changes background color of listviewitem when hover text color doese not change when hover idea please in how can fix help

update: have used usercontrol apply style on listview this:

details.xaml:

<page.resources>         <datatemplate x:key="listviewtemplate">             <local:listviewtemplate content="{binding}"/>         </datatemplate> </page.resources> <listview x:name="listmee" itemtemplate="{staticresource listviewtemplate}">      <listview.itemcontainerstyle>        <!--i have put here style-->      </listview.itemcontainerstyle> </listview> 

details.xaml.cs:

private async void page_loaded(object sender, routedeventargs e)   {    getdayshours(); }         private async void getdayshours()         {               uristring2 = "webservice;                 var http = new httpclient();                 http.maxresponsecontentbuffersize = int32.maxvalue;                 var response = await http.getstringasync(uristring2);                 var rootobject1 = jsonconvert.deserializeobject<nvbarberry.models.rootobject>(response);                  listmee.itemssource = rootobject1.horaire_local;          } 

listviewtemplate.xaml:(usercontrol file)

<stackpanel orientation="horizontal">             <stackpanel  horizontalalignment="left">                 <textblock   x:name="day" text="{binding path=nom_jour}"/>             </stackpanel>             <stackpanel  horizontalalignment="right">           <textblock x:name="hour_deb" text="{binding path=deb_jour}" />           <textblock x:name="hour_fin" text="{binding path=fin_jour}"/>              </stackpanel> </stackpanel> 

when load page empty list,miss thing in code??


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 -