title: Setting focus on a button in xaml and having a text box automatically have the type cursor in it
body: <p>Hello I currently have a xaml form pop up with some text, a text box and button called confirm.</p>
  
  <p>Is there a way I can have the form appear with the cursor already in the text box so that the user can start typing straight away and have focus on the button so that when they press enter, it runs the buttons on_Click handler.</p>
  
  <p>my xaml code is as follows for the textbox and button:</p>
  
  <pre><code>&lt;TextBox x:Name="SessionName"  Grid.Row="4" FontFamily="Calibri" FontSize="14"  IsTabStop="True" TabIndex="1" MaxLines="2" AcceptsTab="True" AcceptsReturn="False" BorderThickness="1" Height="30" Width="300" HorizontalAlignment="Center" Margin="0,5,10,5" ForceCursor="True" &gt;
              &lt;TextBox.ContextMenu&gt;
                  &lt;ContextMenu/&gt;
              &lt;/TextBox.ContextMenu&gt;
          &lt;/TextBox&gt;
  
  &lt;Button x:Name="startAppButton" Content="Start" Grid.Row="5" Height="25" Width="150" Click="StartAppButton_Click" HorizontalAlignment="Center" /&gt;
  </code></pre>
  
  <p>For my .cs file, the code is as follows:</p>
  
  <pre><code>public class Class
  {
      public WelcomePage()
      {
          InitializeComponent();
  
          /*disables window modification.*/
          this.WindowStyle = WindowStyle.None;
      }
  
      public static string sessionName { set; get; }
  
      private void StartAppButton_Click(object sender, RoutedEventArgs e)
      {
           if (SessionName.Text.ToString().Equals(""))
           {
               System.Windows.MessageBox.Show("Please give your session a name", "Error",    
               MessageBoxButton.OK, MessageBoxImage.Error);
           }
           else
           {
               sessionName = SessionName.Text.ToString();
               Calibration.Degree_Choice dc = new Calibration.Degree_Choice();
               this.Hide();
               dc.ShowDialog();
               this.Close();
           }
      } 
  
  }   
  </code></pre>
  
  <p>Any advice as to if this is possible would be greatly appreciated.</p>
  
  <p>J</p>