c# - WPF listview change observable collection properties with button inside ListView Item -


i using wpf list view bound in xaml to observable collection. below list view item template generates view like

listview item looks this

<datatemplate x:key="imageoverlayalbumdatatemplate">   <grid>       <grid margin="5,5,5,5">         <border borderbrush="lightgray" borderthickness="1">         <stackpanel  orientation="vertical" background="white" height="50" width="240" verticalalignment="center">                             <grid>                                 <grid.columndefinitions>                                     <columndefinition width="auto" />                                     <columndefinition  />                                     <columndefinition width="auto" />                                 </grid.columndefinitions>                                 <grid.rowdefinitions>                                     <rowdefinition />                                     <rowdefinition  />                                     <rowdefinition  />                                 </grid.rowdefinitions>                              <border name="actionstatusindicator" height="50" width="7" margin="0" grid.rowspan="2">                                 <border.style>                                     <style targettype="{x:type border}">                                         <style.triggers>                                             <datatrigger binding="{binding path=statusid}" value="3">                                                 <setter property="background" value="steelblue"/>                                             </datatrigger>                                                 <datatrigger binding="{binding path=statusid}" value="4">                                                 <setter property="background" value="lightgray"/>                                             </datatrigger>                                                 <datatrigger binding="{binding path=statusid}" value="5">                                                 <setter property="background" value="orange"/>                                             </datatrigger>                                                 <datatrigger binding="{binding path=statusid}" value="6">                                                 <setter property="background" value="red"/>                                             </datatrigger>                                         </style.triggers>                                     </style>                                 </border.style>                              </border>                             <!--</stackpanel>-->                                 <textblock  text="{binding subject}" margin="10,0,0,0" width="230" height="20" fontsize="13"                                     texttrimming="characterellipsis"  horizontalalignment="left" textalignment="left"                                             grid.row="0" grid.column="1"/>                                  <textblock text="{binding path=displayname}" fontsize="10" margin="10,3,0,0" width="110" height="20"                                  texttrimming="characterellipsis"  horizontalalignment="left" textalignment="left"                                            grid.row="1" grid.column="1"/>                                  <image x:name="sidebutton" source="/icons/action.png" width="20" height="20"  grid.row="1" grid.column="1" horizontalalignment="right" >                                     <image.style>                                         <style targettype="{x:type image}">                                             <setter property="visibility" value="hidden" />                                             <style.triggers>                                                 <datatrigger binding="{binding relativesource={relativesource mode=findancestor,ancestortype={x:type listviewitem}},path=ismouseover}" value="true">                                                      <setter property="visibility" value="visible" />                                                 </datatrigger>                                                  <multidatatrigger>                                                     <multidatatrigger.conditions>                                                         <condition binding="{binding relativesource={relativesource mode=findancestor,ancestortype={x:type listviewitem}},path=ismouseover}" value="true" />                                                         <condition binding="{binding path=statusid}" value="3" />                                                      </multidatatrigger.conditions>                                                     <setter property="visibility" value="visible" />                                                 </multidatatrigger>                                              </style.triggers>                                         </style>                                     </image.style>                                 </image>                              </grid>                      </stackpanel>                     </border>                </grid>             </grid>         </datatemplate> 

i want change 'statusid' other number when user clicks on image (tick) appear on mouse hover.

statusid present in actionview class int , above list bound

change image element button re-template appear image:

   <button width="20" height="20" grid.row="1" grid.column="1" horizontalalignment="right"  command={binding path=changestatuscommand}>         <button.template>             <controltemplate>                 <image x:name="sidebutton" source="/icons/action.png"    > ... 

and maybe wanna move triggers out template or button...

and need create icommand (or implements it) in same object have statusid (or can create somewhere else too, on place need have referense object have statusid) can write c#-code change statusid when pushing image. need make sure statusid property uses inotifypropertychange event alert xaml updated.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -