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

how to get focused item in a page

Closed Thread
 
Thread Tools Display Modes
Old 08-21-2006   #1 (permalink)
Sam Jost
Guest


 

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

Old 08-22-2006   #2 (permalink)
Drew Marsh
Guest


 

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/


Old 08-22-2006   #3 (permalink)
Sam Jost
Guest


 

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

Old 08-24-2006   #4 (permalink)
Marcus
Guest


 

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)...

Old 08-31-2006   #5 (permalink)
Sam Jost
Guest


 

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

Old 09-01-2006   #6 (permalink)
ManniAT
Guest


 

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


Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
page disappears when Mouse moved off page CDNHart General Discussion 10 07-31-2008 05:02 PM
Blue Screen - Page fault in non page area Gregstagg985 Vista performance & maintenance 0 07-22-2008 04:31 PM
Focused Control loosing focus Ronaldo Moreira Vista General 0 04-04-2007 09:54 AM
How to Compose a Page From Grids Defined Outide the Page? Chris Moore Avalon 10 11-11-2006 12:24 PM
Longhorn Server focused NG now up Andre Da Costa [Extended64] Vista General 2 06-08-2006 07:58 PM








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