![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | set focus on a textfield on application startup Hi, I want to set the focus on my textfield when the application starts, but i don't know how to do this. I tried: txtIdentifier.Focus(); in the constructor of the codebehind of the xaml window code, but it seems that the textfield is created after the calling of the constructor. I can't seem to find any properties for the xaml (xml) code to do this. Does anybody know? Thanks. |
| | #2 (permalink) |
| Guest | Re: set focus on a textfield on application startup Bart van der Heijden wrote: > I want to set the focus on my textfield when the application starts, > but i don't know how to do this. > > I tried: > txtIdentifier.Focus(); in the constructor of the codebehind of the > xaml > window code, but it seems that the textfield is created after the > calling of > the constructor. > I can't seem to find any properties for the xaml (xml) code to do > this. > Does anybody know? You cannot access controls in the constructor because they have not been initialized yet. You must wait until the Loaded event of the Window has fired. So if you hook up to the Loaded event of the Window and do the Focus() call in the handler, you should be all set. HTH, Drew ___________________________________ Drew Marsh Chief Software Architect Mimeo.com, Inc. - http://www.mimeo.com Microsoft C# / WPF MVP Weblog - http://blog.hackedbrain.com/ |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Vista Startup Application | Rubens | Vista General | 2 | 03-10-2008 04:18 PM |
| once iTunes looses the input focus, the CDROM device disappears inthe iTunes application | Holger Birkmeyer | Vista General | 2 | 07-18-2007 02:09 PM |
| stop an application loading at startup | Michelle | Vista General | 9 | 07-01-2007 04:30 PM |
| Startup application issue | santosh | Vista General | 0 | 05-01-2007 02:13 AM |
| fast.exe application error on startup | Jim H | Vista account administration | 0 | 06-11-2006 08:50 AM |