Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8446011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:48:47+00:00 2026-06-10T09:48:47+00:00

<Grid x:Name=LayoutRoot> <Button x:Name=BtnNavigateTabIndex Content=NavigateTabIndex Margin=152,200,0,190 HorizontalAlignment=Left Width=120/> <TextBox x:Name=TextBox_1 HorizontalAlignment=Left Height=48 Margin=120,64,0,0 TextWrapping=Wrap

  • 0
<Grid x:Name="LayoutRoot">
    <Button x:Name="BtnNavigateTabIndex" Content="NavigateTabIndex" Margin="152,200,0,190" HorizontalAlignment="Left" Width="120"/>
    <TextBox x:Name="TextBox_1" HorizontalAlignment="Left" Height="48" Margin="120,64,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="80"/>
    <TextBox x:Name="TextBox_2" HorizontalAlignment="Left" Height="48" Margin="120,128,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="80"/>
    <PasswordBox x:Name="PasswordBox_1" HorizontalAlignment="Left" Height="48" Margin="224,64,0,0" VerticalAlignment="Top" Width="72"/>
    <PasswordBox x:Name="PasswordBox_2" HorizontalAlignment="Left" Height="48" Margin="224,128,0,0" VerticalAlignment="Top" Width="72"/>
</Grid>

The design will will be like below.

enter image description here

If i click the button(NavigateTabIndex),The cursor should be navigate to TextBox or PasswordBox.
For EX: If you click the Tab Key in you Keyboard,the cursor would navigate.This is the scenario what i need .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:48:49+00:00Added an answer on June 10, 2026 at 9:48 am

    In general there are a lot of gotchas with WPF focussing….some bugs even.

    You need to understand the difference between Logical and Keyboard focus.

    • http://msdn.microsoft.com/en-us/library/aa969768.aspx

    When using FocusScopes you can use:

    MoveFocus with a TraversalRequest(FocusNavigationDirection.Next)

    to change the logical focus to the next item in the scope.

    An alternative to using FocusScopes is to track the GotFocus/LostFocus events and manage it yourself.

    Some more links:

    • How to programmatically navigate WPF UI element tab stops?

    • Move focus in response to keyboard events in XAML

    • WPF FocusNavigationDirection, MoveFocus and Arrow keys

    • Locating the first WPF tab stop

    • http://www.codeproject.com/Articles/38507/Using-the-WPF-FocusScope


    Ok here’s some example code for you. I took the liberty to redesign your use of the Grid a bit, to follow more conventional layout practice.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    
    namespace WpfApplication5
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void BtnNavigateTabIndex_Click(object sender, RoutedEventArgs e)
            {
                UIElement focussedelement = FocusManager.GetFocusedElement(grid1) as UIElement;
    
                bool bmovedfocus = focussedelement.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
    
                if (bmovedfocus)
                {
                    UIElement withfocusnow = FocusManager.GetFocusedElement(grid1) as UIElement;
    
                    if (withfocusnow == focussedelement) // focus didn't change! because end of focus group..need to put it back to the start
                    {
                        TextBox_1.Focus();
                    }
                }
            }
    
            private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                TextBox_1.Focus();
            }
        }
    }
    
    
        <Window x:Class="WpfApplication5.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:local="clr-namespace:WpfApplication5"
                Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded">
            <StackPanel>
                <Grid x:Name="grid1" FocusManager.IsFocusScope="True">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <TextBox Margin="10" Grid.Row="0" Grid.Column="0" x:Name="TextBox_1" HorizontalAlignment="Left" Height="48" TextWrapping="Wrap" VerticalAlignment="Top" Width="80"/>
                    <PasswordBox Margin="10" Grid.Row="0" Grid.Column="1" x:Name="PasswordBox_1" HorizontalAlignment="Left" Height="48" VerticalAlignment="Top" Width="72"/>
                    <TextBox Margin="10" Grid.Row="1" Grid.Column="0" x:Name="TextBox_2" HorizontalAlignment="Left" Height="48" TextWrapping="Wrap" VerticalAlignment="Top" Width="80"/>
                    <PasswordBox Margin="10" Grid.Row="1" Grid.Column="1" x:Name="PasswordBox_2" HorizontalAlignment="Left" Height="48" VerticalAlignment="Top" Width="72"/>
                    <Button FocusManager.IsFocusScope="True" Padding="20" HorizontalAlignment="Center" Grid.Row="2" Grid.ColumnSpan="2" x:Name="BtnNavigateTabIndex" Content="NavigateTabIndex"  Width="120" Click="BtnNavigateTabIndex_Click" />
                </Grid>
            </StackPanel>
        </Window>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simply view: <Grid x:Name=LayoutRoot> <TextBox Height=23 HorizontalAlignment=Left Margin=66,66,0,0 Name=textBox1 VerticalAlignment=Top Width=120
<Grid x:Name=LayoutRoot> <Button x:Name=btn_num Width=51 Margin=318.849,158,262.15,0 Height=45 VerticalAlignment=Top d:LayoutOverrides=HorizontalMargin> <Grid Height=38.166 Width=44.833> <Label x:Name=lbl_2
Consider the following XAML (a UserControl): <Grid x:Name=LayoutRoot ScrollViewer.VerticalScrollBarVisibility=Disabled> <Grid HorizontalAlignment=Right Width=335.312 ScrollViewer.VerticalScrollBarVisibility=Disabled> <ed:BlockArrow
I have a simple user control with the following content: <Grid x:Name=LayoutRoot> <Button x:Name=btnOpenGenericPage
Here is a part of my DataForm <Grid x:Name=LayoutRoot Background=White> <df:DataForm x:Name=df1 HorizontalAlignment=Stretch VerticalAlignment=Stretch
<Grid x:Name=LayoutRoot> <TextBox x:Name=TxtFocusOut Height=74 Margin=186,149,225,0 TextWrapping=Wrap VerticalAlignment=Top HorizontalContentAlignment=Center VerticalContentAlignment=Center FontSize=26.667 TextChanged=TextBox_TextChanged/> </Grid> private
XAML <Grid x:Name=LayoutRoot Background=White> <Canvas x:Name=VideoCanvas Width=800 Height=600 AllowDrop=True Background=RosyBrown HorizontalAlignment=Center> <StackPanel Drop=VideoCanvas_Drop AllowDrop=True
I have this code in XAML <Grid x:Name=LayoutRoot Background=Transparent> <Grid.RowDefinitions> <RowDefinition Height=Auto/> <RowDefinition Height=*/>
I'm using jqgrid tree grid with the following configuration colModel : [ { name:'id',width
I have the following XAML: <Grid x:Name=LayoutRoot Background=White DataContext={Binding Source={StaticResource MyDataKey}}> <TextBox Name=_myId Text={Binding

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.