// Return proxy representing currently focused element (if any) private object InContextGetFocus(object unused) { // AutomationPeer peer = Peer; if (peer == null) { return(null); } AutomationPeer focusedPeer = AutomationPeer.AutomationPeerFromInputElement(Keyboard.FocusedElement); return(StaticWrap(focusedPeer, peer)); }
// Return proxy representing currently focused element (if any) private object InContextGetFocus() { // Note: - what if a custom element - eg anchor in a text box - has focus? // won't have a UIElement there, can we even find the host? // If it implements Automation, can hand over to it, but if it doesn't, // would like nearest item, drill in using visual tree? AutomationPeer peer = Peer; if (peer == null) { return(null); } AutomationPeer focusedPeer = AutomationPeer.AutomationPeerFromInputElement(Keyboard.FocusedElement); return(StaticWrap(focusedPeer, peer)); }