Question: I'm handling myDialog1\_KeyDown event, and if Enter key is pressed my method moves focus to the next element like this:

```
UIElement focusedElement = Keyboard.FocusedElement as UIElement;
if (focusedElement != null)
{
    if(focusedElement.MoveFocus(newTraversalRequest(FocusNavigationDirection.Next)))
    e.Handled = true;
}

```

myDialog1 is myDockBase object. myDockBase is a class which extends DXWindow and is used for every modal dialog in the app. 

Then problem is when user is positioned on the last field - when he press Enter key focus is moved to the close button (minimize and maximize buttons are hidden) and then if he press Enter again the window is closed.

EDIT: What I want: if close button is focused don't allow user to close window on pressing enter key or don't move focus to close button

Answer: 
A solution might be to forbid the close button to have focus at all, assuming you don't need it. See [Focusable](http://msdn.microsoft.com/en-us/library/system.windows.iinputelement.focusable.aspx) property. If you create the button in code: `closeButton.Focusable = false`. If in XAML: `<Button Focusable="false" Command="...">Close</Button>`. This way when you navigate focus the close button won't appear in the cycle.
You don't say what you expect to happen. You could check if the current control is the last field (you must have an ID for it). If the user is currently in that last field, don't move forward to the next field.