Roland Deschain
Roland Deschain

Reputation: 2850

Label with multiple Targets

To get focus via hotkey on a TextBox or ComboBox for example you need to set a Label with content="_P" (if 'P' is the needed hotkey) and bind the element you want to focus on to the labels target.

I have a user control which is already accessed via a hotkey and contains several TextBoxes and and ComboBoxes, so I want to cycle through them with the same hotkey. Can I assign several targets to one label (How?) or do I need to create a Labelwith the same content for every element?

Upvotes: 0

Views: 85

Answers (1)

Troels Thisted
Troels Thisted

Reputation: 76

In your xaml you can give your elements a "TabIndex", this way you can define the path your "tabs" shall take.

As to if you can assign a specific key to use as the "tab" function i would look into keydown or keyup eventhandlers - I think if you assign the handlers to the user control and then do something like this:

    private void usercontrol_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.A)
        {
            //Design your tab algorithm
        }
    }

hope it helps.

Upvotes: 1

Related Questions