.NET Framework Class Library
ContentPresenter..::.RecognizesAccessKey Property

Gets or sets a value that indicates whether the ContentPresenter should use AccessText in its style. This is a dependency property.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
Syntax

Visual Basic (Declaration)
Public Property RecognizesAccessKey As Boolean
Visual Basic (Usage)
Dim instance As ContentPresenter
Dim value As Boolean

value = instance.RecognizesAccessKey

instance.RecognizesAccessKey = value
C#
public bool RecognizesAccessKey { get; set; }
Visual C++
public:
property bool RecognizesAccessKey {
    bool get ();
    void set (bool value);
}
JScript
public function get RecognizesAccessKey () : boolean
public function set RecognizesAccessKey (value : boolean)
XAML Attribute Usage
<object RecognizesAccessKey="bool" .../>

Property Value

Type: System..::.Boolean
true if the ContentPresenter should use AccessText in its style; otherwise, false. The default is false.
Dependency Property Information

Identifier field

RecognizesAccessKeyProperty

Metadata properties set to true

None

Examples

The following example shows a style for the CheckBox control:

XAML
<Style x:Key="{x:Type CheckBox}" TargetType="CheckBox">
  <Setter Property="SnapsToDevicePixels" Value="true"/>
  <Setter Property="OverridesDefaultStyle" Value="true"/>
  <Setter Property="FocusVisualStyle"    Value="{StaticResource CheckBoxFocusVisual}"/>
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="CheckBox">
        <BulletDecorator Background="Transparent">
          <BulletDecorator.Bullet>
            <Border x:Name="Border"  
              Width="13" 
              Height="13" 
              CornerRadius="0" 
              Background="{StaticResource NormalBrush}"
              BorderThickness="1"
              BorderBrush="{StaticResource NormalBorderBrush}">
              <Path 
                Width="7" Height="7" 
                x:Name="CheckMark"
                SnapsToDevicePixels="False" 
                Stroke="{StaticResource GlyphBrush}"
                StrokeThickness="2"
                Data="M 0 0 L 7 7 M 0 7 L 7 0" />
            </Border>
          </BulletDecorator.Bullet>
          <ContentPresenter Margin="4,0,0,0"
            VerticalAlignment="Center"
            HorizontalAlignment="Left"
            RecognizesAccessKey="True"/>
        </BulletDecorator>
        <ControlTemplate.Triggers>
          <Trigger Property="IsChecked" Value="false">
            <Setter TargetName="CheckMark" Property="Visibility" Value="Collapsed"/>
          </Trigger>
          <Trigger Property="IsChecked" Value="{x:Null}">
            <Setter TargetName="CheckMark" Property="Data" Value="M 0 7 L 7 0" />
          </Trigger>
          <Trigger Property="IsMouseOver" Value="true">
            <Setter TargetName="Border" Property="Background" Value="{StaticResource DarkBrush}" />
          </Trigger>
          <Trigger Property="IsPressed" Value="true">
            <Setter TargetName="Border" Property="Background" Value="{StaticResource PressedBrush}" />
            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource PressedBorderBrush}" />
          </Trigger>
          <Trigger Property="IsEnabled" Value="false">
            <Setter TargetName="Border" Property="Background" Value="{StaticResource DisabledBackgroundBrush}" />
            <Setter TargetName="Border" Property="BorderBrush" Value="{StaticResource DisabledBorderBrush}" />
            <Setter Property="Foreground" Value="{StaticResource DisabledForegroundBrush}"/>
          </Trigger>
        </ControlTemplate.Triggers>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

For more information about this example, see CheckBox ControlTemplate Example.

Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Other Resources

Tags :


Community Content

KitWest
Beware when changing Content if it doesn't initially include an underscore
If you have button captions in multiple languages, for instance, and not all translations have an underscore, if your Button.Content starts out without an underscore but is changed, the underscore will appear as an extra character in the button caption; the ContentPresenter's RecognizesAccessKey is ineffective under these circumstances.
Tags :

Page view tracker