The first step in internationalizing an application is to ensure that your application honors the user’s current regional settings, as reflected by the CurrentCulture property of the application’s main thread.

Current culture impacts not only how you display the following types of data, but also how the user inputs this data:

Numeric data

Date/time values

These values are typically stored internally as numeric (e.g. double, int) or DateTime values. The values exist in memory in a culture-agnostic form. You need to worry about regional settings only when you display a value to the user or receive input from the user.

In .NET, if you use the Parse method of a numeric or date/time type to convert a user-supplied string to the internal type, the parse operation will expect the string to be in a format that is valid for the current region.

A user interface element has a CommandBindings collection containing command binding objects that indicate which commands are supported for the element and the code that the command is bound to.

User interface elements also have an InputBindings collection that contains KeyBinding and MouseBinding instances, each of which maps keyboard or mouse input to a command that is also present in the CommandBindings collection.

In the code below, we wire up the Open command for both key (Ctrl+O) and mouse (Ctrl+Left Click) input.

In keypress events, you can check to see if the user is also holding down one of the modifier keys (Ctrl, Alt, Shift, or Windows key). You do this by checking the KeyEventArgs.KeyboardDevice.Modifiers property.

You sometimes want to check to see if one and only one modifier key is being held down (e.g. Ctrl key without Alt, Shift, or Windows). You do this by checking to see if the Modifiers property is equal to one of the ModifierKeys enumerated values.

Note that this method doesn’t distinguish between whether you pressed the left vs. right Ctrl keys. This is normally what you want. If you do want to distinguish between the two, you can explicitly check for left vs. right.

You can set up a trigger that fires whenever a control’s IsKeyboardFocused property becomes true, changing the value of some other property when the control gains keyboard focus.

You can also trigger on the IsKeyboardFocusWithin property. This property will get set to true for an element when any child of that element has keyboard focus.

In the example below, we set the background color of either StackPanel when any element within the StackPanel has focus. This technique may be useful when you want to keep track of what section of a window the user is working in and do something based on that knowledge.

You can add your own triggers related to keyboard focus by defining a custom property trigger. The XAML fragment below defines a new Style element that changes the Background of the control when IsKeyboardFocused is true.