![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| | #6 (permalink) |
| | 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 Specs![]() |
| 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 | |||