Reader Level:
Articles

WPF AccessText

By Mahesh Chand on November 10, 2012
This article demonstrates how to use an AccessText control in WPF using XAML and C#.
  • 0
  • 0
  • 7794

WPF AccessText Control

The AccessText control in WPF converts a character preceded by an underscore to an Access Key. The Access Key is registered and therefore raises an event when pressed.

This article demonstrates how to create and use an AccessText control in WPF using XAML and C#.

Creating an AccessText

The AccessText element represents an AccessText control in XAML. 

<AccessText>_Click Me</AccessText> 

The following code snippet adds an AccessText to a Button control. The button control click event will be raised when you select the ALT+C keys on the keyboard.

<Button Name="Button1" Width="120" Height="50" Margin="33,70,59,124"
        FontSize="16" Click="Button1_Click">
    <AccessText>_Click Me</AccessText>
</Button>   

If there are multiple underscore characters, only the first one is converted into an AccessKey; the other underscores appear as normal text. If the underscore that you want converted to the access key is not the first underscore, use two consecutive underscores for any underscores that precede the one that you want to convert. 

Mahesh Chand

Mahesh Chand is founder of C# Corner. C# Corner founded in 1999 is a FREE member contributions based open platform for developers to solve problems, learn new technology and hang out.  Mahesh has been awar... Read more

COMMENT USING

Trending up