Export (0) Print
Expand All

AccessText Class

Specifies with an underscore the character that is used as the access key.

Namespace: System.Windows.Controls
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[ContentPropertyAttribute("Text")] 
public class AccessText : FrameworkElement, IAddChild
/** @attribute ContentPropertyAttribute("Text") */ 
public class AccessText extends FrameworkElement implements IAddChild
ContentPropertyAttribute("Text") 
public class AccessText extends FrameworkElement implements IAddChild
<AccessText>
  Text
</AccessText>

The access key is the character that immediately follows the underscore, as this example shows:

<Button Click="edit_Click">
  <AccessText>_Edit</AccessText>
</Button>
<Button Click="cut_Click">_Cut</Button>

If your content has 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. For example, the following code contains an access key and displays as _HelloWorld:

<AccessText>__Hello_World</AccessText>

Because the underscore that precedes H is a double, the W key registers as the access key.

To use AccessText as a content host in a control style, set RecognizesAccessKey in the ContentPresenter, as this example shows:

<ContentPresenter RecognizesAccessKey="True"/>

Optionally, use AccessText internally, as this example shows: <Button>_Hello</Button>.

You can use the AccessText tag to create an AccessKey; however, a tag is not necessary. The following example shows how to create an access key by only using an underline character.

<Button Click="edit_Click">
  <AccessText>_Edit</AccessText>
</Button>
<Button Click="cut_Click">_Cut</Button>

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
            System.Windows.Controls.AccessText

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show:
© 2014 Microsoft