Skip to content

Commit

Permalink
Adding automation peer for TextBox #647
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Nov 12, 2018
1 parent 26033f3 commit c27c046
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Fluent.Ribbon/Automation/Peers/ButtonAutomationPeer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class ButtonAutomationPeer : System.Windows.Automation.Peers.ButtonAutoma
{
/// <summary>Initializes a new instance of the <see cref="T:ButtonAutomationPeer" /> class.</summary>
/// <param name="owner">The element associated with this automation peer.</param>
public ButtonAutomationPeer([NotNull]Button owner)
public ButtonAutomationPeer([NotNull] Button owner)
: base(owner)
{
}
Expand Down
32 changes: 32 additions & 0 deletions Fluent.Ribbon/Automation/Peers/TextBoxAutomationPeer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
namespace Fluent.Automation.Peers
{
using JetBrains.Annotations;

/// <inheritdoc />
public class TextBoxAutomationPeer : System.Windows.Automation.Peers.TextBoxAutomationPeer
{
/// <summary>Initializes a new instance of the <see cref="T:TextBoxAutomationPeer" /> class.</summary>
/// <param name="owner">The element associated with this automation peer.</param>
public TextBoxAutomationPeer([NotNull] TextBox owner)
: base(owner)
{
}

/// <inheritdoc />
protected override string GetNameCore()
{
var text = base.GetNameCore();
var owner = (IHeaderedControl)this.Owner;

if (string.IsNullOrEmpty(text))
{
if (owner.Header is string headerString)
{
return headerString;
}
}

return text;
}
}
}

0 comments on commit c27c046

Please sign in to comment.