0

So i have a view with a bunch of buttons, and a single textbox :

   <TextBox Name="InputField" Text="{Binding Path=InputField, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

i want at all times keep focus in this textbox because this textbox is used for very many different things. Right now if i click on buttons in the same view, focus is lost and i cant really figure out how to "catch" that focus is lost so i can focus textbox again.

How do i achieve this?

Timsen
  • 4,066
  • 10
  • 59
  • 117

2 Answers2

3

Use TextBox.OnLostFocus event a handler when focus lost reset it I hope it will resolve your issue.

Other way is to set focus to your textbox on buttons mouse key down event.

look here the way to achieve what you are trying Set focus on textbox in WPF from view model (C#)

Community
  • 1
  • 1
Abdul Rehman
  • 415
  • 5
  • 16
-1

try add

InputField.Focus(); 

on the end of button's click event.

darson1991
  • 406
  • 6
  • 18