This project is read-only.

Fluent.TextBox focus problem

Jun 9, 2011 at 10:44 AM

I have a Fluent Text Box defined in the XAML <Fluent:TextBox Name="rbTxtBoxName" ...>

I want to set the cursor (focus) to it when a button is clicked. So far, I have been unsuccessful.

I have tried the following in the button click event

rbTxtBoxName.Focus(); --> doesnt work


Keyboard.Focus(rbTxtBoxName); -->doesn't work


rbTxtBoxName.RaiseEvent(new RoutedEventArgs(Fluent.TextBox.Mous

eDoubleClickEvent)); -->doesn't work

Any help will be appreciate it. Thanks
Jun 14, 2011 at 5:32 PM

Has anyone experienced this? or has any ideas?

Jun 16, 2011 at 5:42 AM

try               txtLastName.Focus(); where txtLastName is the name you set in XAML portion 

for example:


<TextBox Grid.Column="1" Grid.Row="0"  Margin="5,0,0,0" VerticalAlignment="Stretch" x:Name="txtLastName"  />


       private void buttonCreateNewContact_Click(object sender, RoutedEventArgs e)
                 txtStatus.Text = "Management Mode - Create New Contact";                

Jun 16, 2011 at 11:13 PM

Hi Adam,

Thanks for your input. Setting the textbox.focus() was the first thing I tried which it did not work.

Setting the focus in wpf text boxes this way works fine, but not if it is a fluent:textbox.  This Fluent:TextBox resides in the Fluent:Ribbon.

I have tried some other ways, like the ones mentioned on my first post, but nothing seems to work!


Jun 17, 2011 at 6:22 AM

Why use a Fluent textbox over a wpf textbox?

Jul 30, 2011 at 1:12 PM

I had the same issue and find a solution to it. I'm not sure if this solution will always work but for now it's fine:

I discovered that after setting the focus via code when I press the Tab Key the focus will be in the textbox. Maybe the Fluent Textbox consists of the icon in front of it an the textbox itself. Setting the focus brings the focus only to some invisible control and sending a TAB brings it to the textbox.

In my code I use the following snippet:


TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);

Where _SearchText is a Fluent TextBox