Click here to Skip to main content
15,891,847 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

I am trying to set the initial focus on a certain Textbox within my UserControl, by doing the following:
FocusManager.FocusedElement="{Binding ElementName=txtBarCode}"

A. It sets the focus, but the cursor does not flicker? Only when I click on the Textbox, does it start flickering?
B. Secondly, how can I keep the focus on the Textbox.

Many thanks in advance!
Kind regards
Posted

1 solution

To set logical focus to an input control
FocusManager.SetFocusedElement(this, textboxJack);  


or

Use this code:

private void Button_Click(object sender, RoutedEventArgs e)
{
    textBox.Focus();
    textBox.SelectionStart = textName.Text.Length;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900