Skip to content

Commit

Permalink
Adding automation peer for RadioButton #647
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Nov 12, 2018
1 parent 4c22e96 commit 2768363
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
32 changes: 32 additions & 0 deletions Fluent.Ribbon/Automation/Peers/RadioButtonAutomationPeer.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 RadioButtonAutomationPeer : System.Windows.Automation.Peers.RadioButtonAutomationPeer
{
/// <summary>Initializes a new instance of the <see cref="T:RadioButtonAutomationPeer" /> class.</summary>
/// <param name="owner">The element associated with this automation peer.</param>
public RadioButtonAutomationPeer([NotNull] RadioButton 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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/// <inheritdoc />
public class ToggleButtonAutomationPeer : System.Windows.Automation.Peers.ToggleButtonAutomationPeer
{
/// <summary>Initializes a new instance of the <see cref="T:TextBoxAutomationPeer" /> class.</summary>
/// <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 ToggleButtonAutomationPeer([NotNull] ToggleButton owner)
: base(owner)
Expand Down
7 changes: 7 additions & 0 deletions Fluent.Ribbon/Controls/RadioButton.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,11 @@ void ILogicalChildSupport.RemoveLogicalChild(object child)
{
this.RemoveLogicalChild(child);
}

/// <inheritdoc />
protected override AutomationPeer OnCreateAutomationPeer()
{
return new Fluent.Automation.Peers.RadioButtonAutomationPeer(this);
}
}
}

0 comments on commit 2768363

Please sign in to comment.