Roman Starkov
Roman Starkov

Reputation: 61510

Can a WPF Label be configured to focus the next item in the tab order when the access key is pressed?

In WinForms, the control focused when a label's access key is pressed is determined by the tab order. Since one has to get the tab order right anyway, the label targets were essentially "effort-free" in WinForms.

It's quite a bit more effort on WPF: each and every Label's Target must be painstakingly specified by name. It can't even be clicked on the form preview (at least not within Visual Studio 2010 - I don't know about Expression).

Can this be simplified or even completely automated, like it was in WinForms?

Upvotes: 4

Views: 300

Answers (1)

Gishu
Gishu

Reputation: 136673

Source: MS Forum

Seems like this one missed the release bus this time. So you need to manually set the properties on the UI elements for now.

Update: Seems like I'm confused as to your exact question.

  1. If it is about setting the keyboard navigation order for an entire form quickly, then the KeyboardNavigation class is what you should be after. There is no designer support as of now.
  2. If it is hookup a label with a corresponding control, such that pressing an accelerator key moves focus to the control - then you need to manually set the Label's target property. Even in Winforms, I think you had to go and modify each label to specify the exact character/accelerator. (The _ or & character before the mnemonic)

Upvotes: 1

Related Questions