Skip to content

Commit

Permalink
Adding automation peer for CheckBox #647
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Dec 3, 2018
1 parent 66dfa77 commit 8ff8d68
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Fluent.Ribbon/Automation/Peers/CheckBoxAutomationPeer.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 CheckBoxAutomationPeer : System.Windows.Automation.Peers.ToggleButtonAutomationPeer
{
/// <summary>Initializes a new instance of the <see cref="T:ToggleButtonAutomationPeer" /> class.</summary>
/// <param name="owner">The element associated with this automation peer.</param>
public CheckBoxAutomationPeer([NotNull] CheckBox 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;
}
}
}
4 changes: 4 additions & 0 deletions Fluent.Ribbon/Controls/CheckBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Fluent
{
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Data;
using System.Windows.Markup;
using Fluent.Internal.KnownBoxes;
Expand Down Expand Up @@ -196,5 +197,8 @@ void ILogicalChildSupport.RemoveLogicalChild(object child)
{
this.RemoveLogicalChild(child);
}

/// <inheritdoc />
protected override AutomationPeer OnCreateAutomationPeer() => new Fluent.Automation.Peers.CheckBoxAutomationPeer(this);
}
}

0 comments on commit 8ff8d68

Please sign in to comment.