.net - How to unfocus TextBox without focusing something else -


i believe when application starts nothing focused. @ least looks it. add event handler gotfocus event control shows popup , loses focus, popup can shown again without manually removing focus , setting back. not needed have textbox in focused visual state cause serving no use user (this can changed template though answer on question resolves both issues).

if mistaken initial observation , focused in silverlight know focus looks nothing focused (like when app starts). if there way remove visible focus - such approach better.

edit: in case turned out control had no visualstyle difference when focused focused @ start of application. didn't find smarter focus in unfocus() related method.. go bit further can recommend hitting [enter] key , see happens, in case changed focused control state, looked unfocused.

note taken : in silverlight there no "nothing focused state"

focus in silverlight notoriously difficult manage.

there lots of controls can have focus show no visual difference when have focus - different winforms.

i've found useful following class useful in of silverlight apps try figure out focus problems:

public static class watchwhatsgotfocus {     private static dispatchertimer t;      public static void startwatching()     {         t = new dispatchertimer();         t.interval = timespan.frommilliseconds(500);         t.tick += t_tick;         t.start();     }      public static void stopwatching()     {         if (t != null)         {             t.stop();             t = null;         }     }      static void t_tick(object sender, eventargs e)     {         var element = focusmanager.getfocusedelement();                     if (element != null)             debug.writeline("focused element: {0}", element.tostring());         else         {             debug.writeline("no focused element");         }     } } 

so, somewhere in app, call watchwhatsgotfocus.startwatching() , you'll see what's going on.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -