Skip to content

Commit

Permalink
Adding automation peer for ComboBox #647
Browse files Browse the repository at this point in the history
  • Loading branch information
batzen committed Nov 12, 2018
1 parent 2768363 commit 92d5c32
Show file tree
Hide file tree
Showing 3 changed files with 40 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
@@ -1,7 +1,7 @@
namespace Fluent.Automation.Peers
{
using JetBrains.Annotations;

/// <inheritdoc />
public class ButtonAutomationPeer : System.Windows.Automation.Peers.ButtonAutomationPeer
{
Expand Down
32 changes: 32 additions & 0 deletions Fluent.Ribbon/Automation/Peers/ComboBoxAutomationPeer.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 ComboBoxAutomationPeer : System.Windows.Automation.Peers.ComboBoxAutomationPeer
{
/// <summary>Initializes a new instance of the <see cref="T:ComboBoxAutomationPeer" /> class.</summary>
/// <param name="owner">The element associated with this automation peer.</param>
public ComboBoxAutomationPeer([NotNull] ComboBox 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;
}
}
}
7 changes: 7 additions & 0 deletions Fluent.Ribbon/Controls/ComboBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Fluent
{
using System;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
Expand Down Expand Up @@ -846,5 +847,11 @@ void ILogicalChildSupport.RemoveLogicalChild(object child)
{
this.RemoveLogicalChild(child);
}

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

0 comments on commit 92d5c32

Please sign in to comment.