diff --git a/ModernWpf.Controls/CommandBarFlyout/CommandBarFlyoutToolBar.cs b/ModernWpf.Controls/CommandBarFlyout/CommandBarFlyoutToolBar.cs
index 64456daa..e28cef9f 100644
--- a/ModernWpf.Controls/CommandBarFlyout/CommandBarFlyoutToolBar.cs
+++ b/ModernWpf.Controls/CommandBarFlyout/CommandBarFlyoutToolBar.cs
@@ -633,7 +633,15 @@ void EnsureAutomationSetCountAndPosition()
{
if (command is UIElement commandAsUIElement)
{
- if (commandAsUIElement.Visibility == Visibility.Visible)
+ // Don't count AppBarSeparator if IsTabStop is false
+ if (commandAsUIElement is AppBarSeparator separator)
+ {
+ if (!separator.IsTabStop)
+ {
+ continue;
+ }
+ }
+ else if (commandAsUIElement.Visibility == Visibility.Visible)
{
sizeOfSet++;
}
@@ -650,7 +658,15 @@ void EnsureAutomationSetCountAndPosition()
{
if (command is UIElement commandAsUIElement)
{
- if (commandAsUIElement.Visibility == Visibility.Visible)
+ // Don't count AppBarSeparator if IsTabStop is false
+ if (commandAsUIElement is AppBarSeparator separator)
+ {
+ if (!separator.IsTabStop)
+ {
+ continue;
+ }
+ }
+ else if (commandAsUIElement.Visibility == Visibility.Visible)
{
AutomationProperties.SetSizeOfSet(commandAsUIElement, sizeOfSet);
}
@@ -868,7 +884,7 @@ bool IsControlFocusable(
return control != null &&
control.Visibility == Visibility.Visible &&
control.IsEnabled &&
- (!checkTabStop || control.IsTabStop);
+ (control.IsTabStop || (!checkTabStop && !(control is AppBarSeparator))); // AppBarSeparator is not focusable if IsTabStop is false
}
Control GetFirstTabStopControl(
diff --git a/test/ModernWpfTestApp/CommandBarFlyoutPage.xaml b/test/ModernWpfTestApp/CommandBarFlyoutPage.xaml
index 5a4de40f..dd5e2999 100644
--- a/test/ModernWpfTestApp/CommandBarFlyoutPage.xaml
+++ b/test/ModernWpfTestApp/CommandBarFlyoutPage.xaml
@@ -23,6 +23,7 @@
Opened="OnFlyoutOpened"
Closed="OnFlyoutClosed">
+
@@ -30,6 +31,7 @@
+