![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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. |
My System Specs![]() |
| | #2 (permalink) |
| | 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/ |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Focus on application startup | .NET General | |||
| Focus 6 Startup: Delete? Computer Access Damaged | Software | |||
| Give focus to an InternetExplorer.Application object | VB Script | |||
| Vista Startup Application | Vista General | |||
| once iTunes looses the input focus, the CDROM device disappears inthe iTunes application | Vista General | |||