Mega Code Archive

 
Categories / C# Tutorial / WPF
 

Focus a TextBox

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();             } }