Search code examples
c#xamlwindows-store-appstextblock

Set TabIndex to TextBlock


I'm developing Windows Store application, using C# + XAML. I have a textblock, used as activation button for HeaderMenu with a chevron character inside it and Tap event binded. How can I activate it by keyboard only?

Should I set TabIndex attribute on it? If yes, how?


Solution

  • You can use the KeyboardNavigation.TabIndex on the <TextBlock... />

    <TextBlock Text="Focusable TextBlock"
                   Focusable="True"
                   KeyboardNavigation.TabIndex="4"
                   Margin="5"/>