开发者

Create Alt-key shortcuts in WPF/XAML

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜