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
Post a Comment