Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing focus of child element in a UserControl to parent in WPF

Tags:

.net

wpf

xaml

I have a complex WPF UserControl made of other ContentControl templates which contain sets of buttons, textfields, and other elements.

The parent UC is focusable so I have a style with a property trigger to update (gratuitous OuterGlowBitmapEffect) when the UC has focus. However when the user clicks or tabs to any of the buttons inside the UC the focus is lost. I would like to maintain the glow while using the UC.

Can I pass the focus from the child controls up to the UC?

like image 511
Jippers Avatar asked Jan 08 '09 00:01

Jippers


1 Answers

You should be able to base your property trigger on the IsKeyboardFocusWithin property, which returns true if any child element has focus.

like image 102
Matt Hamilton Avatar answered Nov 18 '22 07:11

Matt Hamilton