Search This Blog

Showing posts with label FrameworkElementFactory. Show all posts
Showing posts with label FrameworkElementFactory. Show all posts

Thursday, March 2, 2017

FrameworkElementFactory focus on load element

WPF > FrameworkElementFactory > AddHandler


FrameworkElementFactory textBox = new FrameworkElementFactory(typeof(TextBox));
textBox.AddHandler(TextBox.LoadedEvent, new RoutedEventHandler(OnTextBoxLoaded));

private void OnTextBoxLoaded(object sender, RoutedEventArgs e)
{
       TextBox textBox = sender as TextBox;
       if (textBox != null)
       {
              textBox.Focus();
       }
}