Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - how to get focused item in a page

 
 
Old 08-21-2006   #1 (permalink)
Sam Jost


 
 

how to get focused item in a page

I've got a browser-like WPF app, and would like to know what element in
my page currently is focused.

There seems to be no 'currentfocus' element in a page, and I'm a bit
stumped how to get the current focus of my app/page.
Probably I'm missing something very obvious here

Can someone help?
Thanks,
Sam


My System SpecsSystem Spec
Old 08-22-2006   #2 (permalink)
Drew Marsh


 
 

Re: how to get focused item in a page

> I've got a browser-like WPF app, and would like to know what element
> in my page currently is focused.
>
> There seems to be no 'currentfocus' element in a page, and I'm a bit
> stumped how to get the current focus of my app/page.
> Probably I'm missing something very obvious here
> Can someone help?


Check out the static FocusManager::FocusedElement[1] property.

HTH,
Drew

[1] http://windowssdk.msdn.microsoft.com...edelement.aspx

___________________________________
Drew Marsh
Chief Software Architect
Mimeo.com, Inc. - http://www.mimeo.com
Microsoft C# / WPF MVP
Weblog - http://blog.hackedbrain.com/


My System SpecsSystem Spec
Old 08-22-2006   #3 (permalink)
Sam Jost


 
 

Re: how to get focused item in a page


Drew Marsh schrieb:

> > There seems to be no 'currentfocus' element in a page, and I'm a bit
> > stumped how to get the current focus of my app/page.
> > Probably I'm missing something very obvious here
> > Can someone help?

>
> Check out the static FocusManager::FocusedElement[1] property.


I tried FocusManager.GetFocusedElement(), but it always returns null in
my case

I'll dig around the FocusManager some more tomorrow though, thanks.

Sam

My System SpecsSystem Spec
Old 08-24-2006   #4 (permalink)
Marcus


 
 

Re: how to get focused item in a page

Sam Jost wrote:
> Drew Marsh schrieb:
>
> > > There seems to be no 'currentfocus' element in a page, and I'm a bit
> > > stumped how to get the current focus of my app/page.
> > > Probably I'm missing something very obvious here
> > > Can someone help?

> >
> > Check out the static FocusManager::FocusedElement[1] property.

>
> I tried FocusManager.GetFocusedElement(), but it always returns null in
> my case
>
> I'll dig around the FocusManager some more tomorrow though, thanks.
>
> Sam


I`d be interested in knowing about your findings on your FocusManager
digging...

In the mean-time, I did work around that "problem" by using the
Keyboard.FocusedElement property..

This solution is however far from perfect since the KeyboardFocus
"drops" when application becomes inactive (keyboard focus in another
application)...

My System SpecsSystem Spec
Old 08-31-2006   #5 (permalink)
Sam Jost


 
 

Re: how to get focused item in a page


Marcus schrieb:

> Sam Jost wrote:
> > Drew Marsh schrieb:
> >
> > > > There seems to be no 'currentfocus' element in a page, and I'm a bit
> > > > stumped how to get the current focus of my app/page.
> > > > Probably I'm missing something very obvious here
> > > > Can someone help?
> > >
> > > Check out the static FocusManager::FocusedElement[1] property.

> >
> > I tried FocusManager.GetFocusedElement(), but it always returns null in
> > my case
> >
> > I'll dig around the FocusManager some more tomorrow though, thanks.
> >
> > Sam

>
> I`d be interested in knowing about your findings on your FocusManager
> digging...
>
> In the mean-time, I did work around that "problem" by using the
> Keyboard.FocusedElement property..


Well, I didn't even start digging, since your post does contain my
answer: I was looking for the keyboard focus, thats exactly the one I
needed.

> This solution is however far from perfect since the KeyboardFocus
> "drops" when application becomes inactive (keyboard focus in another
> application)...


*scratches head* I got to check this, maybe I'll run into the same
problems.

Thanks,
Sam

My System SpecsSystem Spec
Old 09-01-2006   #6 (permalink)
ManniAT


 
 

Re: how to get focused item in a page

Hi,

just thinking about the keyboard focus problem.
Your app must be (at least one time) active - then you will get the KF Element.
When another app gains the focus you will have no KF element - am I right?

Idea: track the KF element in the manner of "CurrentKeyBoardFocusElement".
When your app loses focus this element still points to the control which was focused before.
So this should be the element you are looking for - no matter if you are active or not.

Regards

Manfred


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
rename-item, move-item and special chars. PowerShell
Copy-Item : Container cannot be copied onto existing leaf item. PowerShell
Focused Control loosing focus Vista General
Longhorn Server focused NG now up Vista General


Vista Forums 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 Ltd

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