Skip to content

Commit 8ba1da4

Browse files
committed
Merge branch 'master' into develop
2 parents 9cff476 + 2165d04 commit 8ba1da4

File tree

7 files changed

+75
-8
lines changed

7 files changed

+75
-8
lines changed

Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog for Fluent.Ribbon
22

3+
## 10.0.2
4+
5+
- ### Bug fixes
6+
7+
- [#1125](../../issues/1125) - BackStage Back Button doesn't have an accessibility text.
8+
39
## 10.0.1
410

511
- ### Bug fixes

Fluent.Ribbon.Showcase/TestContent.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
<Grid>
178178
<!-- Backstage items can be keytipped -->
179179
<Fluent:Backstage x:Name="Backstage"
180+
AutomationProperties.Name="Backstage"
180181
IsOpen="{Binding IsBackstageOpen, Mode=TwoWay}"
181182
Visibility="Collapsed">
182183
<Fluent:Backstage.ToolTip>
@@ -317,6 +318,7 @@
317318
</Fluent:Backstage>
318319

319320
<Fluent:ApplicationMenu x:Name="ApplicationMenu"
321+
AutomationProperties.Name="Application menu"
320322
Visibility="Collapsed">
321323
<Fluent:ApplicationMenu.RightPaneContent>
322324
<StackPanel HorizontalAlignment="Stretch"

Fluent.Ribbon/Automation/Peers/RibbonBackstageTabControlAutomationPeer.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
namespace Fluent.Automation.Peers;
22

3+
using System.Collections.Generic;
34
using System.Windows.Automation.Peers;
45
using System.Windows.Automation.Provider;
6+
using Fluent.Extensions;
7+
using Fluent.Internal;
58

69
/// <summary>
710
/// Automation peer for <see cref="BackstageTabControl" />.
@@ -34,4 +37,22 @@ protected override ItemAutomationPeer CreateItemAutomationPeer(object item)
3437
bool ISelectionProvider.IsSelectionRequired => true;
3538

3639
bool ISelectionProvider.CanSelectMultiple => false;
40+
41+
/// <inheritdoc />
42+
protected override List<AutomationPeer> GetChildrenCore()
43+
{
44+
var baseResult = base.GetChildrenCore() ?? new List<AutomationPeer>();
45+
46+
if (this.OwningBackstageTabControl.BackButton is { } backButton)
47+
{
48+
var backButtonAutomationPeer = backButton.GetOrCreateAutomationPeer();
49+
50+
if (backButtonAutomationPeer is not null)
51+
{
52+
baseResult.Insert(0, backButtonAutomationPeer);
53+
}
54+
}
55+
56+
return baseResult;
57+
}
3758
}

Fluent.Ribbon/Automation/Peers/RibbonTabControlAutomationPeer.cs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
namespace Fluent.Automation.Peers;
22

33
using System.Collections.Generic;
4+
using System.Linq;
45
using System.Windows;
56
using System.Windows.Automation.Peers;
67
using System.Windows.Automation.Provider;
8+
using Fluent.Extensions;
9+
using Fluent.Internal;
710

811
/// <summary>
912
/// Automation peer for <see cref="RibbonTabControl"/>.
@@ -81,9 +84,29 @@ protected override List<AutomationPeer> GetChildrenCore()
8184
{
8285
var children = base.GetChildrenCore() ?? new List<AutomationPeer>();
8386

84-
var toolbarPanel = this.OwningRibbonTabControl.ToolbarPanel;
87+
if (this.OwningRibbonTabControl.Menu is { } menu)
88+
{
89+
var automationPeer = menu.GetOrCreateAutomationPeer();
90+
91+
if (automationPeer is null)
92+
{
93+
var child = UIHelper.GetVisualChildren(menu)
94+
.OfType<UIElement>()
95+
.FirstOrDefault(x => x.IsVisible);
96+
97+
if (child is not null)
98+
{
99+
automationPeer = child.GetOrCreateAutomationPeer();
100+
}
101+
}
85102

86-
if (toolbarPanel is not null)
103+
if (automationPeer is not null)
104+
{
105+
children.Insert(0, automationPeer);
106+
}
107+
}
108+
109+
if (this.OwningRibbonTabControl.ToolbarPanel is { } toolbarPanel)
87110
{
88111
foreach (UIElement? child in toolbarPanel.Children)
89112
{
@@ -92,7 +115,7 @@ protected override List<AutomationPeer> GetChildrenCore()
92115
continue;
93116
}
94117

95-
var automationPeer = CreatePeerForElement(child);
118+
var automationPeer = child.GetOrCreateAutomationPeer();
96119

97120
if (automationPeer is not null)
98121
{
@@ -101,11 +124,9 @@ protected override List<AutomationPeer> GetChildrenCore()
101124
}
102125
}
103126

104-
var displayOptionsButton = this.OwningRibbonTabControl.DisplayOptionsControl;
105-
106-
if (displayOptionsButton is not null)
127+
if (this.OwningRibbonTabControl.DisplayOptionsControl is { } displayOptionsButton)
107128
{
108-
var automationPeer = CreatePeerForElement(displayOptionsButton);
129+
var automationPeer = displayOptionsButton.GetOrCreateAutomationPeer();
109130

110131
if (automationPeer is not null)
111132
{

Fluent.Ribbon/Controls/BackstageTabControl.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace Fluent;
2121
/// </summary>
2222
[TemplatePart(Name = "PART_SelectedContentHost", Type = typeof(ContentPresenter))]
2323
[TemplatePart(Name = "PART_ItemsPanelContainer", Type = typeof(UIElement))]
24+
[TemplatePart(Name = "PART_BackButton", Type = typeof(UIElement))]
2425
public class BackstageTabControl : Selector, ILogicalChildSupport
2526
{
2627
#region Properties
@@ -29,6 +30,8 @@ public class BackstageTabControl : Selector, ILogicalChildSupport
2930

3031
internal UIElement? ItemsPanelContainer { get; private set; }
3132

33+
internal UIElement? BackButton { get; private set; }
34+
3235
/// <summary>Identifies the <see cref="BackButtonUid"/> dependency property.</summary>
3336
public static readonly DependencyProperty BackButtonUidProperty = DependencyProperty.Register(
3437
nameof(BackButtonUid), typeof(string), typeof(BackstageTabControl), new PropertyMetadata(default(string)));
@@ -329,6 +332,7 @@ public override void OnApplyTemplate()
329332

330333
this.ItemsPanelContainer = this.GetTemplateChild("PART_ItemsPanelContainer") as UIElement;
331334
this.SelectedContentHost = this.GetTemplateChild("PART_SelectedContentHost") as ContentPresenter;
335+
this.BackButton = this.GetTemplateChild("PART_BackButton") as UIElement;
332336
}
333337

334338
/// <inheritdoc />
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Fluent.Extensions;
2+
3+
using System.Windows;
4+
using System.Windows.Automation.Peers;
5+
6+
internal static class UIElementExtensions
7+
{
8+
public static AutomationPeer? GetOrCreateAutomationPeer(this UIElement element)
9+
{
10+
return UIElementAutomationPeer.FromElement(element)
11+
?? UIElementAutomationPeer.CreatePeerForElement(element);
12+
}
13+
}

Fluent.Ribbon/Themes/Controls/BackstageTabControl.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@
197197
VerticalAlignment="Top"
198198
IsEnabled="{TemplateBinding IsWindowSteeringHelperEnabled}" />
199199

200-
<Button x:Name="backbutton"
200+
<Button x:Name="PART_BackButton"
201201
Uid="{TemplateBinding BackButtonUid}"
202202
Style="{DynamicResource Fluent.Ribbon.Styles.BackstageBackButton}"
203203
Grid.Row="0"

0 commit comments

Comments
 (0)