private void GetProfileNameDialogWindow_Loaded(object sender, RoutedEventArgs e)
 {
     // We need to schedule this to occur later after databinding has completed, otherwise
     // focus appears in the textbox, but at the start of the suggested name rather than at
     // the end.
     Dispatcher.BeginInvoke(
         (SetFocusCallback) delegate()
     {
         ProfileNameTextBox.Select(0, ProfileNameTextBox.Text.Length);
         ProfileNameTextBox.Focus();
     }, System.Windows.Threading.DispatcherPriority.DataBind, null);
 }
Ejemplo n.º 2
0
        private void GetProfileNameDialogWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // We need to schedule this to occur later after databinding has completed, otherwise
            // focus appears in the textbox, but at the start of the suggested name rather than at
            // the end.
#pragma warning disable VSTHRD001 // Avoid legacy threading switching APIs.
                                  // see https://github.com/Microsoft/vs-threading/issues/138
                                  // There is currently no better way to queue an item on
                                  // DispatcherPriority.DataBind until the above issue is fixed
            Dispatcher.BeginInvoke(
                (SetFocusCallback) delegate()
            {
                ProfileNameTextBox.Select(0, ProfileNameTextBox.Text.Length);
                ProfileNameTextBox.Focus();
            }, System.Windows.Threading.DispatcherPriority.DataBind, null);
#pragma warning restore VSTHRD001 // Avoid legacy threading switching APIs
        }
        /// <summary>
        /// Called when window loads. Use it to set focus on the text box correctly.
        /// </summary>
        private void GetProfileNameDialogWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // We need to schedule this to occur later after databinding has completed, otherwise
            // focus appears in the textbox, but at the start of the suggested name rather than at
            // the end.

            JoinableTaskFactory jtfWithPriority = _threadingService.JoinableTaskFactory
                                                  .WithPriority(Dispatcher, System.Windows.Threading.DispatcherPriority.DataBind);

            _ = jtfWithPriority.RunAsync(
                () =>
            {
                ProfileNameTextBox.Select(0, ProfileNameTextBox.Text.Length);
                ProfileNameTextBox.Focus();
                return(Task.CompletedTask);
            });
        }