Browse Source

Added ShowAccessKey property to AccessText.

pull/58/head
Steven Kirk 11 years ago
parent
commit
e04e5cc632
  1. 17
      Perspex.Controls/Primitives/AccessText.cs

17
Perspex.Controls/Primitives/AccessText.cs

@ -13,6 +13,21 @@ namespace Perspex.Controls.Primitives
/// </summary>
public class AccessText : TextBlock
{
/// <summary>
/// Defines the <see cref="ShowAccessKey"/> property.
/// </summary>
public static readonly PerspexProperty<bool> ShowAccessKeyProperty =
PerspexProperty.Register<AccessText, bool>("ShowAccessKey", inherits: true);
/// <summary>
/// Gets or sets a value indicating whether the access key should be underlined.
/// </summary>
public bool ShowAccessKey
{
get { return this.GetValue(ShowAccessKeyProperty); }
set { this.SetValue(ShowAccessKeyProperty, value); }
}
/// <summary>
/// Renders the <see cref="AccessText"/> to a drawing context.
/// </summary>
@ -23,7 +38,7 @@ namespace Perspex.Controls.Primitives
int underscore = this.Text?.IndexOf('_') ?? -1;
if (underscore != -1)
if (underscore != -1 && this.ShowAccessKey)
{
var rect = this.FormattedText.HitTestTextPosition(underscore);
var offset = new Vector(0, -0.5);

Loading…
Cancel
Save