data binding - Setting focus to UI control in WPF MVVM Way on Validation.HasError -


problem: validation.haserror automatically highlights control has error via inotifydataerrorinfo implementation.

my problem need set focus on specific control when has error.

how do that?

i have gone through several articles in stackoverflow , other sites , wish address problem.

   <style targettype="textbox" >                         <setter property="overridesdefaultstyle" value="false"/>                         <setter property="verticalalignment" value="center"/>                         <setter property="horizontalalignment" value="left"/>                         <setter property="margin" value="5,3" />                         <style.triggers>                             <trigger property="validation.haserror" value="true">                                 <setter property="focusmanager.focusedelement" value="{binding relativesource={relativesource self}}"/>                             </trigger>                         </style.triggers>                     </style> 

setting focusedelement did trick. :) can used set focus using boolean property in viewmodel via datatrigger simple trigger.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -