views:

491

answers:

3

Hi

I have a WPF window which is divided into two portions. One portion contains itemscontrol which generate textboxes depedning on observable collection binding in ViewModel.

The other portion of window has a content control which loads a usercontrol using datatemplate and viewmodel binding. Also that user control has buttons on it.

The problem is i want to keep keyboard focus within the textboxes in itemscontrol at all times and don't want the keyboard focus to shift to the usercontrol button even if they are pressed.

Currently the keyboardfocus shift from the text boxes to the usercontrol buttons when the button is pressed.

Is there a way i can keep keyboard focus in textbox in itemscontrol.

A: 

I am just shooting in the dark, but here is something you can try: in your user control set Focusable to false and FocusManager.IsFocusScope attached property to true.

idursun
A: 

What about changing the focus back to the textbox in the button click event?

Carlo
+1  A: 

Setting Focusable="false" on the buttons should be sufficient.

Joe White