Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

set focus on a textfield on application startup

Closed Thread
 
Thread Tools Display Modes
Old 03-23-2006   #1 (permalink)
Bart van der Heijden
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.
Old 03-23-2006   #2 (permalink)
Drew Marsh
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/


Closed Thread

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








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50