c# - How to show programmatically FocusVisualStyle? -
afters attemps tell focusvisualstyle activated keyboard (tab , arrows keys).
try make focusvisualstyle applied after component loaded, impossible do, there easy way around problem?
i found this:
- focus visual not showing when navigating focus programically
- how wpf buttons decide show focusvisualstyle?
- http://social.msdn.microsoft.com/forums/en-us/wpf/thread/99856840-f8ef-4547-9150-c4c46ec2f3df
but none shows definite solution (without overwriting component), , not write, can help?
i not pretty sure understand issue, tried example in 1 of links , able move focus next component code behind using keyboard. here code.
<window x:class="wpfapplication1.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" title="mainwindow" height="350" width="525" xmlns:local="clr-namespace:wpfapplication1" loaded="onloaded" > <stackpanel margin="10"> <textbox margin="10" x:name="a" >a</textbox> <textbox margin="10" x:name="b" >b</textbox> <button focusable="false" click="onclick">move focus</button> </stackpanel> </window> public partial class mainwindow : window { public mainwindow() { initializecomponent(); } private void onloaded(object sender, routedeventargs e) { a.focus(); } private void onclick(object sender, routedeventargs e) { var request = new traversalrequest(focusnavigationdirection.next); var elementwithfocus = focusmanager.getfocusedelement(focustest) uielement; if (elementwithfocus != null) elementwithfocus.movefocus(request); } }
Comments
Post a Comment