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 3786508
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T11:41:39+00:00 2026-05-19T11:41:39+00:00

Is anyone aware of a free or commercial WPF control that would do something

  • 0

Is anyone aware of a free or commercial WPF control that would do something like this:

alt text

X character per box, and auto-tabbing to the next box as you complete each box? Similar to the way that license keys are entered for Microsoft products.

I don’t think it would be particularly hard to do from scratch, but I’d like to avoid reinventing the wheel if a good example of this already exists.

  • 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-05-19T11:41:39+00:00Added an answer on May 19, 2026 at 11:41 am

    WPF provides all you need except auto-tabbing to the next control. A behavior can provide that functionality and the result looks like this:

    <Grid>
        <Grid.Resources>
            <local:KeyTextCollection x:Key="keys"/>
        </Grid.Resources>
        <StackPanel>
            <ItemsControl ItemsSource="{StaticResource keys}" Focusable="False">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal" Background="AliceBlue"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <TextBox Text="{Binding Text}" Margin="5" MaxLength="4" Width="40">
                            <i:Interaction.Behaviors>
                                <local:TextBoxBehavior AutoTab="True" SelectOnFocus="True"/>
                            </i:Interaction.Behaviors>
                        </TextBox>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </StackPanel>
    </Grid>
    

    Here are the KeyText and KeyTextCollection classes (adjust to taste):

    class KeyText
    {
        public string Text { get; set; }
    }
    
    class KeyTextCollection : List<KeyText>
    {
        public KeyTextCollection()
        {
            for (int i = 0; i < 4; i++) Add(new KeyText { Text = "" });
        }
    }
    

    And here is the behavior that implements auto-tab and select-on-focus:

    public class TextBoxBehavior : Behavior<TextBox>
    {
        public bool SelectOnFocus
        {
            get { return (bool)GetValue(SelectOnFocusProperty); }
            set { SetValue(SelectOnFocusProperty, value); }
        }
    
        public static readonly DependencyProperty SelectOnFocusProperty = 
            DependencyProperty.Register("SelectOnFocus", typeof(bool), typeof(TextBoxBehavior), new UIPropertyMetadata(false));
    
        public bool AutoTab
        {
            get { return (bool)GetValue(AutoTabProperty); }
            set { SetValue(AutoTabProperty, value); }
        }
    
        public static readonly DependencyProperty AutoTabProperty =
            DependencyProperty.Register("AutoTab", typeof(bool), typeof(TextBoxBase), new UIPropertyMetadata(false));
    
        protected override void OnAttached()
        {
            AssociatedObject.PreviewGotKeyboardFocus += (s, e) =>
            {
                if (SelectOnFocus)
                {
                    Action action = () => AssociatedObject.SelectAll();
                    AssociatedObject.Dispatcher.BeginInvoke(action, DispatcherPriority.ContextIdle);
                }
            };
            AssociatedObject.TextChanged += (s, e) =>
            {
                if (AutoTab)
                {
                    if (AssociatedObject.Text.Length == AssociatedObject.MaxLength &&
                        AssociatedObject.SelectionStart == AssociatedObject.MaxLength)
                    {
                        AssociatedObject.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
                    }
                }
            };
        }
    }
    

    If you are not familiar with behaviors, Install the Expression Blend 4 SDK and add this namespaces:

    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    

    and add System.Windows.Interactivity to your project.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is anyone aware of a free utility, preferably with source code, that will create
Is anyone aware of any lock-free skiplist implimentations and/or research papers that support the
Is anyone aware of any method (or external plugin) that would allow for nested
Is anyone aware of a script/class (preferably in PHP) that would parse a given
is anyone aware of lightweight restful lib that is namespaced following psr-0 guide lines.
Is anyone aware of a category on NSString or NSMutableString that allows for templating?
Apart from lxml , is anyone aware of Python packages that depend on libxml2
Before I go ahead and write something myself is anyone aware of a library
Is anyone aware of a free web service which allows me to translate uk
Is anyone aware of a Visual Studio 2010 Add-In that will automatically allow you

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.