开发者

Create Alt-key shortcuts in WPF/XAML

开发者 https://www.devze.com 2022-12-10 05:03 出处:网络
I have a XAML window with multiple TextBoxes, each with a corresponding TextBlock tag for a title.I would like to enable Alt-key shortcu开发者_Python百科ts for this window (hold down the Alt key to sh

I have a XAML window with multiple TextBoxes, each with a corresponding TextBlock tag for a title. I would like to enable Alt-key shortcu开发者_Python百科ts for this window (hold down the Alt key to show underlined letters in the TextBlock titles, type one of those letters and focus should change to the corresponding TextBox).

I've found out how to do a similar thing for menu items (place an underscore in the title for the menu), but how does one go about doing it for other items in a window in this case?


Instead of using TextBlock, use the Label control. It has intrinsic support for associating a mnemonic with another control via it's Target property. To choose the character that will represent the alt+ you simply prefix it with an _ (underscore) in the Label's Content.

0

精彩评论

暂无评论...
验证码 换一张
取 消