In Windows and other operating systems, it's a widespread practice to access the controls in a window by holding the Alt key and then pressing a character defined as its access key. For example, to open the File menu of any Windows application, we use Alt + F. Here, the character F is the access key, which gets invoked when we press Alt.
Let's learn how to add an access key to labels in the WPF application, using the Label control. Create a new project called CH02.LabelAccessKeyDemo, open the MainWindow.xaml page, and replace the default Grid by a StackPanel. Now add two labels and two textboxes inside the StackPanel, as follows:
<StackPanel Margin="10 10 10 20"> <Label Content="Enter _Username:" Target="{Binding ElementName=txbUsername}" /> <TextBox x:Name="txbUsername" Margin="6 0" /> <Label Content="Enter _Password:" Target="...