tags:

views:

521

answers:

1

I am writing a control in WPF that draws a shape on a form and then draws dimensions of this shape. These dimensions are editable so they are shown in a text box. When the user changes a dimension in a text box the shape is updated.

I am updating the shape when the textbox showing the dimension loses focus i.e. as soon as the text box loses the focus the shape and all the dimensions are redrawn. A text box loses focus in one of two ways - either when user presses tab key or when user clicks in another control outside the text box.

My problem is that when user presses tab key or clicks somewhere else outside the text box the whole control is redrawn and the focus is not set to the next control where it should be. This is really annoying because tabs stop working altogether and to set a focus using mouse the user has to click twice. Is there a way around this?

An image of my control is shown below

alt text

+1  A: 

It seems that you want to manage the tab order yourself in this window and to do that, I'd think you would subscribe to the GotKeyboardFocus and LostKeyboardFocus events on those edit fields and then drive focus to the appropriate location if you're not happy with where focus has gone.

jschroedl