I don't think it's possible, at least not without some extra boilerplate code... WPF and Windows Forms have a completely different model, and the Target
property isn't designed to refer to WinForms controls.
Instead, I think you should use a WPF implementation of MaskedTextBox
, like this one (you can find many other examples with Google). Using WinForms controls in a WPF app is rarely a good idea if you can avoid it...
EDIT: I just checked the doc : it is definitely not possible to do what you want, because the type of the Label.Target
property is UIElement
, and WinForms controls are clearly not UIElement
s...
UPDATE: OK, I misread your code... you're referencing the WindowsFormsHost
, which is a UIElement
. Whoever voted me up was wrong too ;-)
I think the problem is that the WindowsFormsHost
takes the focus when you press Alt-S, not the MaskedTextBox
. Here's a quick workaround :
XAML :
<WindowsFormsHost
Name="tbStartTime"
TabIndex="13"
GotFocus="tbStartTime_GotFocus">
<wf:MaskedTextBox Name="wfStartTime" Mask="90:00" />
</WindowsFormsHost>
Code-behind :
private void tbStartTime_GotFocus(object sender, RoutedEventArgs e)
{
tbStartTime.Child.Focus();
}
Anyway, my previous advice is still relevant : you'd better use a WPF MaskedTextBox...