diff --git a/src/MahApps.Metro/Automation/Peers/WindowCommandsAutomationPeer.cs b/src/MahApps.Metro/Automation/Peers/WindowCommandsAutomationPeer.cs
new file mode 100644
index 0000000000..d90c325581
--- /dev/null
+++ b/src/MahApps.Metro/Automation/Peers/WindowCommandsAutomationPeer.cs
@@ -0,0 +1,65 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Windows;
+using System.Windows.Automation.Peers;
+using JetBrains.Annotations;
+using MahApps.Metro.Controls;
+
+namespace MahApps.Metro.Automation.Peers
+{
+ public class WindowCommandsAutomationPeer : FrameworkElementAutomationPeer
+ {
+ public WindowCommandsAutomationPeer([NotNull] WindowCommands owner)
+ : base(owner)
+ {
+ }
+
+ ///
+ protected override string GetClassNameCore()
+ {
+ return "WindowCommands";
+ }
+
+ ///
+ protected override AutomationControlType GetAutomationControlTypeCore()
+ {
+ return AutomationControlType.ToolBar;
+ }
+
+ ///
+ protected override string GetNameCore()
+ {
+ string nameCore = base.GetNameCore();
+
+ if (string.IsNullOrEmpty(nameCore))
+ {
+ nameCore = ((WindowCommands)this.Owner).Name;
+ }
+
+ if (string.IsNullOrEmpty(nameCore))
+ {
+ nameCore = this.GetClassNameCore();
+ }
+
+ return nameCore;
+ }
+
+ ///
+ protected override bool IsOffscreenCore()
+ {
+ return !((WindowCommands)this.Owner).HasItems || base.IsOffscreenCore();
+ }
+
+ protected override Point GetClickablePointCore()
+ {
+ if (!((WindowCommands)this.Owner).HasItems)
+ {
+ return new Point(double.NaN, double.NaN);
+ }
+
+ return base.GetClickablePointCore();
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/MahApps.Metro/Controls/MetroWindow.cs b/src/MahApps.Metro/Controls/MetroWindow.cs
index da29e1b905..ae6acb4827 100644
--- a/src/MahApps.Metro/Controls/MetroWindow.cs
+++ b/src/MahApps.Metro/Controls/MetroWindow.cs
@@ -9,6 +9,7 @@
using System.Linq;
using System.Reflection;
using System.Windows;
+using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Input;
@@ -129,8 +130,30 @@ public class MetroWindow : Window
public static readonly DependencyProperty IconTemplateProperty = DependencyProperty.Register(nameof(IconTemplate), typeof(DataTemplate), typeof(MetroWindow), new PropertyMetadata(null));
public static readonly DependencyProperty TitleTemplateProperty = DependencyProperty.Register(nameof(TitleTemplate), typeof(DataTemplate), typeof(MetroWindow), new PropertyMetadata(null));
- public static readonly DependencyProperty LeftWindowCommandsProperty = DependencyProperty.Register(nameof(LeftWindowCommands), typeof(WindowCommands), typeof(MetroWindow), new PropertyMetadata(null, UpdateLogicalChilds));
- public static readonly DependencyProperty RightWindowCommandsProperty = DependencyProperty.Register(nameof(RightWindowCommands), typeof(WindowCommands), typeof(MetroWindow), new PropertyMetadata(null, UpdateLogicalChilds));
+ public static readonly DependencyProperty LeftWindowCommandsProperty = DependencyProperty.Register(nameof(LeftWindowCommands), typeof(WindowCommands), typeof(MetroWindow), new PropertyMetadata(null, OnLeftWindowCommandsPropertyChanged));
+
+ private static void OnLeftWindowCommandsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ if (e.NewValue is WindowCommands windowCommands)
+ {
+ AutomationProperties.SetName(windowCommands, nameof(LeftWindowCommands));
+ }
+
+ UpdateLogicalChilds(d, e);
+ }
+
+ public static readonly DependencyProperty RightWindowCommandsProperty = DependencyProperty.Register(nameof(RightWindowCommands), typeof(WindowCommands), typeof(MetroWindow), new PropertyMetadata(null, OnRightWindowCommandsPropertyChanged));
+
+ private static void OnRightWindowCommandsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ if (e.NewValue is WindowCommands windowCommands)
+ {
+ AutomationProperties.SetName(windowCommands, nameof(RightWindowCommands));
+ }
+
+ UpdateLogicalChilds(d, e);
+ }
+
public static readonly DependencyProperty WindowButtonCommandsProperty = DependencyProperty.Register(nameof(WindowButtonCommands), typeof(WindowButtonCommands), typeof(MetroWindow), new PropertyMetadata(null, UpdateLogicalChilds));
public static readonly DependencyProperty LeftWindowCommandsOverlayBehaviorProperty = DependencyProperty.Register(nameof(LeftWindowCommandsOverlayBehavior), typeof(WindowCommandsOverlayBehavior), typeof(MetroWindow), new PropertyMetadata(WindowCommandsOverlayBehavior.Never, OnShowTitleBarPropertyChangedCallback));
diff --git a/src/MahApps.Metro/Controls/WindowCommands.cs b/src/MahApps.Metro/Controls/WindowCommands.cs
index 1c8736c653..3b4e4b1418 100644
--- a/src/MahApps.Metro/Controls/WindowCommands.cs
+++ b/src/MahApps.Metro/Controls/WindowCommands.cs
@@ -8,10 +8,12 @@
using System.ComponentModel;
using System.Linq;
using System.Windows;
+using System.Windows.Automation.Peers;
using System.Windows.Controls;
using System.Windows.Data;
using ControlzEx;
using ControlzEx.Theming;
+using MahApps.Metro.Automation.Peers;
using MahApps.Metro.ValueBoxes;
namespace MahApps.Metro.Controls
@@ -358,5 +360,13 @@ private void WindowCommandsLoaded(object sender, RoutedEventArgs e)
this.SetValue(ParentWindowPropertyKey, window);
}
}
+
+ ///
+ /// Creates AutomationPeer ()
+ ///
+ protected override AutomationPeer OnCreateAutomationPeer()
+ {
+ return new WindowCommandsAutomationPeer(this);
+ }
}
}
\ No newline at end of file
diff --git a/src/MahApps.Metro/Themes/WindowCommands.xaml b/src/MahApps.Metro/Themes/WindowCommands.xaml
index a2c18d312c..2dacb5e38e 100644
--- a/src/MahApps.Metro/Themes/WindowCommands.xaml
+++ b/src/MahApps.Metro/Themes/WindowCommands.xaml
@@ -185,6 +185,7 @@