What do I need to do to the following code so that the cursor is blinking in the second textbox when the window appears?
XAML:
<Window x:Class="TestFocksdfj.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<StackPanel HorizontalAlignment="Left" Margin="10">
<ContentControl x:Name="FormArea"/>
</StackPanel>
</Window>
Code Behind:
using System.Windows;
using System.Windows.Controls;
namespace TestFocksdfj
{
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
StackPanel sp = new StackPanel();
for (int i = 0; i < 3; i++)
{
TextBox tb = new TextBox();
tb.Width = 200;
tb.Margin = new Thickness { Bottom = 3 };
if (i == 1)
tb.Focus();
sp.Children.Add(tb);
}
FormArea.Content = sp;
}
}
}