Focus a TextBox : Focus « Windows Presentation Foundation « C# / CSharp Tutorial






using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media;

public class MeetTheDockers : Window
{
    [STAThread]
    public static void Main()
    {
        Application app = new Application();
        app.Run(new MeetTheDockers());
    }
    public MeetTheDockers()
    {
        DockPanel dock = new DockPanel();
        Content = dock;

        TextBox txtbox = new TextBox();
        txtbox.AcceptsReturn = true;

        dock.Children.Add(txtbox);

        txtbox.Focus();        

    }
}








24.165.Focus
24.165.1.Fire an event when an element gains and loses focus.Fire an event when an element gains and loses focus.
24.165.2.Focus a TextBox
24.165.3.Set Focus to TextBox