Quantcast
Channel: WPF and initial focus - Stack Overflow
Viewing all articles
Browse latest Browse all 13

Answer by Vladik Y for WPF and initial focus

$
0
0

Had same problem solved it with simple solution:In the main window:

<Window ....        FocusManager.FocusedElement="{Binding ElementName=usercontrolelementname}"         ... />

In the user control:

private void UserControl_GotFocus_1(object sender, RoutedEventArgs e)        {            targetcontrol.Focus();            this.GotFocus -= UserControl_GotFocus_1;  // to set focus only once        }

Viewing all articles
Browse latest Browse all 13

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>