xaml - Wait for binding update, then lose focus on ListViewItem -


so have listview. has itemsource , selecteditem.

the selecteditem has bool property toggles visibility of button , textbox.

when press in listviewitem want able toggle visibility on , off, if spam row.

the solution partly working, except selecteditem fired when item don't have focus. when have toggled 1 time, have item toggle first again.

enter image description here

i have thought code-behind, add gotfocus-method, can't think of have there.

suggestions?

xaml:

<listview scrollviewer.verticalscrollmode="disabled"                         scrollviewer.verticalscrollbarvisibility="disabled"                           scrollviewer.isverticalrailenabled="false"                          background="white"                 itemssource="{binding activities}"               selecteditem="{binding selectedactivity, mode=twoway}">         <listview.itemcontainerstyle>             <style targettype="listviewitem">                 <setter property="horizontalcontentalignment" value="stretch" />                 <setter property="template">                     <setter.value>                         <controltemplate targettype="listviewitem">                             <listviewitempresenter                         contenttransitions="{templatebinding contenttransitions}"                         selectioncheckmarkvisualenabled="true"                         checkbrush="{themeresource systemcontrolforegroundbasemediumhighbrush}"                         checkboxbrush="{themeresource systemcontrolforegroundbasemediumhighbrush}"                         dragbackground="{themeresource listviewitemdragbackgroundthemebrush}"                         dragforeground="{themeresource listviewitemdragforegroundthemebrush}"                         focusborderbrush="{themeresource systemcontrolforegroundalthighbrush}"                         focussecondaryborderbrush="{themeresource systemcontrolforegroundbasehighbrush}"                         placeholderbackground="white"                         pointeroverbackground="lightgray"                         pointeroverforeground="darkgray"                         selectedbackground="white"                         selectedforeground="dimgray"                         selectedpointeroverbackground="white"                         pressedbackground="white"                         selectedpressedbackground="white"                         disabledopacity="{themeresource listviewitemdisabledthemeopacity}"                         dragopacity="{themeresource listviewitemdragthemeopacity}"                         reorderhintoffset="{themeresource listviewitemreorderhintthemeoffset}"                         horizontalcontentalignment="{templatebinding horizontalcontentalignment}"                         verticalcontentalignment="{templatebinding verticalcontentalignment}"                         contentmargin="{templatebinding padding}"                         checkmode="inline"/>                         </controltemplate>                     </setter.value>                     </setter>             </style>         </listview.itemcontainerstyle>          <listview.header>             <stackpanel background="#8c8c8c"                                      orientation="horizontal"                                      flowdirection="lefttoright"                                      padding="8,8,8,8">                 <textblock text="{binding title}"                                                          fontsize="18"                                                          foreground="white"                                                          horizontalalignment="left"                                                          verticalalignment="center"                                                          margin="10,0,0,0"/>             </stackpanel>         </listview.header>         <listview.itemtemplate>             <datatemplate>                 <grid margin="0,10,0,10">                     <grid.rowdefinitions>                         <rowdefinition height="*"/>                         <rowdefinition height="*"/>                         <rowdefinition height="*"/>                     </grid.rowdefinitions>                     <grid.columndefinitions>                         <columndefinition width="200"/>                         <columndefinition width="*"/>                     </grid.columndefinitions>                     <stackpanel orientation="vertical"                                          grid.row="0"                                          grid.rowspan="2"                                          grid.column="0"                                         verticalalignment="center"                                          horizontalalignment="left"                                         margin="6,2,6,2">                         <textblock fontsize="20"                                             verticalalignment="center"                                            foreground="dimgray"                                             textwrapping="wrapwholewords"                                            text="{binding activity.description}"/>                         <textblock fontsize="15"                                             verticalalignment="center"                                            foreground="dimgray"                                             text="{binding activity.condition}"/>                     </stackpanel>                      <button grid.row="0"                                      grid.column="1"                                      grid.rowspan="2"                                      margin="6"                                     verticalalignment="center"                                     horizontalalignment="right"                                     background="transparent"                                     borderbrush="transparent"                                     borderthickness="0"                                     command="{binding togglemeasurecompletioncommand}">                         <grid>                             <textblock fontfamily="segoe mdl2 assets"                                             fontsize="35"                                             foreground="dimgray"                                             text="&#xe739;"                                             margin="8"                                             verticalalignment="center"                                             horizontalalignment="right"                                             visibility="{binding iscompleted, converter={staticresource inversebooleantovisibilityconverter}}"/>                             <textblock fontfamily="segoe mdl2 assets"                                             fontsize="35"                                             foreground="dimgray"                                             text="&#xe73a;"                                             margin="8"                                             verticalalignment="center"                                             horizontalalignment="right"                                             visibility="{binding iscompleted, converter={staticresource booltovis}}"/>                         </grid>                     </button>                     <grid visibility="{binding isinfocus, converter={staticresource booltovis}}" grid.row="2" grid.column="0" grid.columnspan="2" margin="0,10,0,0">                         <grid.columndefinitions>                             <columndefinition width="*"/>                             <columndefinition width="auto"/>                         </grid.columndefinitions>                         <textbox grid.column="0" placeholdertext="kommentar til tiltak" horizontalalignment="stretch" padding="5" margin="0,0,10,0"/>                         <button grid.column="1" content="flag" horizontalalignment="right" foreground="white" padding="10,5,10,5">                             <button.background>                                 <solidcolorbrush color="red" opacity="0.5" />                             </button.background>                         </button>                     </grid>                 </grid>             </datatemplate>         </listview.itemtemplate>     </listview> 

c# - property:

public selecteditemviewmodel selectedactivity         {             { return _selectedactivity; }             set             {                 _selectedactivity = value;                 selectedactivity.isinfocus = !selectedactivity.isinfocus;                 onpropertychanged();             }         } 

write code selectedactivity.isinfocus = !selectedactivity.isinfocus inside itemclick event of listview. can write inside taped event


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -