diff --git a/src/Avalonia.Controls/Primitives/ScrollBar.cs b/src/Avalonia.Controls/Primitives/ScrollBar.cs
index c780d0d168..f889941e4f 100644
--- a/src/Avalonia.Controls/Primitives/ScrollBar.cs
+++ b/src/Avalonia.Controls/Primitives/ScrollBar.cs
@@ -548,58 +548,69 @@ namespace Avalonia.Controls.Primitives
private ContextMenu CreateVerticalContextMenu()
{
var contextMenu = new ContextMenu();
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.ScrollHere, "ScrollHere", () => ScrollHereAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarScrollHere", "ScrollHere", () => ScrollHereAction(this)));
contextMenu.Items.Add(new Separator());
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.Top, "Top", () => ScrollToTopAction(this)));
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.Bottom, "Bottom", () => ScrollToBottomAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarTop", "Top", () => ScrollToTopAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarBottom", "Bottom", () => ScrollToBottomAction(this)));
contextMenu.Items.Add(new Separator());
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.PageUp, "PageUp", () => PageUpAction(this)));
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.PageDown, "PageDown", () => PageDownAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarPageUp", "PageUp", () => PageUpAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarPageDown", "PageDown", () => PageDownAction(this)));
contextMenu.Items.Add(new Separator());
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.ScrollUp, "ScrollUp", () => LineUpAction(this)));
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.ScrollDown, "ScrollDown", () => LineDownAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarScrollUp", "ScrollUp", () => LineUpAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarScrollDown", "ScrollDown", () => LineDownAction(this)));
return contextMenu;
}
private ContextMenu CreateHorizontalContextMenuLTR()
{
var contextMenu = new ContextMenu();
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.ScrollHere, "ScrollHere", () => ScrollHereAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarScrollHere", "ScrollHere", () => ScrollHereAction(this)));
contextMenu.Items.Add(new Separator());
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.LeftEdge, "LeftEdge", () => ScrollToLeftEndAction(this)));
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.RightEdge, "RightEdge", () => ScrollToRightEndAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarLeftEdge", "LeftEdge", () => ScrollToLeftEndAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarRightEdge", "RightEdge", () => ScrollToRightEndAction(this)));
contextMenu.Items.Add(new Separator());
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.PageLeft, "PageLeft", () => PageLeftAction(this)));
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.PageRight, "PageRight", () => PageRightAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarPageLeft", "PageLeft", () => PageLeftAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarPageRight", "PageRight", () => PageRightAction(this)));
contextMenu.Items.Add(new Separator());
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.ScrollLeft, "ScrollLeft", () => LineLeftAction(this)));
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.ScrollRight, "ScrollRight", () => LineRightAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarScrollLeft", "ScrollLeft", () => LineLeftAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarScrollRight", "ScrollRight", () => LineRightAction(this)));
return contextMenu;
}
private ContextMenu CreateHorizontalContextMenuRTL()
{
var contextMenu = new ContextMenu();
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.ScrollHere, "ScrollHere", () => ScrollHereAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarScrollHere", "ScrollHere", () => ScrollHereAction(this)));
contextMenu.Items.Add(new Separator());
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.RightEdge, "RightEdge", () => ScrollToRightEndAction(this)));
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.LeftEdge, "LeftEdge", () => ScrollToLeftEndAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarRightEdge", "RightEdge", () => ScrollToRightEndAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarLeftEdge", "LeftEdge", () => ScrollToLeftEndAction(this)));
contextMenu.Items.Add(new Separator());
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.PageRight, "PageRight", () => PageRightAction(this)));
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.PageLeft, "PageLeft", () => PageLeftAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarPageRight", "PageRight", () => PageRightAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarPageLeft", "PageLeft", () => PageLeftAction(this)));
contextMenu.Items.Add(new Separator());
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.ScrollRight, "ScrollRight", () => LineRightAction(this)));
- contextMenu.Items.Add(CreateMenuItem(ScrollBarResources.ScrollLeft, "ScrollLeft", () => LineLeftAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarScrollRight", "ScrollRight", () => LineRightAction(this)));
+ contextMenu.Items.Add(CreateMenuItem("StringScrollBarScrollLeft", "ScrollLeft", () => LineLeftAction(this)));
return contextMenu;
}
- private static MenuItem CreateMenuItem(string header, string automationId, Action action)
+ private MenuItem CreateMenuItem(string resourceKey, string automationId, Action action)
{
var menuItem = new MenuItem
{
- Header = header,
Command = new SimpleCommand(action)
};
+
+ if (this.TryFindResource(resourceKey, out var resource) && resource is string header)
+ {
+ menuItem.Header = header;
+ }
+ else
+ {
+ // If we can't get one, fall back to the resource key itself
+ // So at least something is there.
+ menuItem.Header = resourceKey.Replace("StringScrollBar", "").Replace("ScrollBar", "");
+ }
+
AutomationProperties.SetAutomationId(menuItem, automationId);
return menuItem;
}
diff --git a/src/Avalonia.Controls/Primitives/ScrollBarResources.cs b/src/Avalonia.Controls/Primitives/ScrollBarResources.cs
deleted file mode 100644
index 19a7ab31de..0000000000
--- a/src/Avalonia.Controls/Primitives/ScrollBarResources.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-namespace Avalonia.Controls.Primitives
-{
- ///
- /// Provides customizable resource strings for ScrollBar context menu items.
- ///
- public static class ScrollBarResources
- {
- ///
- /// Gets or sets the text for "Scroll Here" menu item.
- ///
- public static string ScrollHere { get; set; } = "Scroll Here";
-
- ///
- /// Gets or sets the text for "Top" menu item.
- ///
- public static string Top { get; set; } = "Top";
-
- ///
- /// Gets or sets the text for "Bottom" menu item.
- ///
- public static string Bottom { get; set; } = "Bottom";
-
- ///
- /// Gets or sets the text for "Page Up" menu item.
- ///
- public static string PageUp { get; set; } = "Page Up";
-
- ///
- /// Gets or sets the text for "Page Down" menu item.
- ///
- public static string PageDown { get; set; } = "Page Down";
-
- ///
- /// Gets or sets the text for "Scroll Up" menu item.
- ///
- public static string ScrollUp { get; set; } = "Scroll Up";
-
- ///
- /// Gets or sets the text for "Scroll Down" menu item.
- ///
- public static string ScrollDown { get; set; } = "Scroll Down";
-
- ///
- /// Gets or sets the text for "Left Edge" menu item.
- ///
- public static string LeftEdge { get; set; } = "Left Edge";
-
- ///
- /// Gets or sets the text for "Right Edge" menu item.
- ///
- public static string RightEdge { get; set; } = "Right Edge";
-
- ///
- /// Gets or sets the text for "Page Left" menu item.
- ///
- public static string PageLeft { get; set; } = "Page Left";
-
- ///
- /// Gets or sets the text for "Page Right" menu item.
- ///
- public static string PageRight { get; set; } = "Page Right";
-
- ///
- /// Gets or sets the text for "Scroll Left" menu item.
- ///
- public static string ScrollLeft { get; set; } = "Scroll Left";
-
- ///
- /// Gets or sets the text for "Scroll Right" menu item.
- ///
- public static string ScrollRight { get; set; } = "Scroll Right";
- }
-}
diff --git a/src/Avalonia.Themes.Fluent/Strings/InvariantResources.xaml b/src/Avalonia.Themes.Fluent/Strings/InvariantResources.xaml
index fa20725e21..9607f11328 100644
--- a/src/Avalonia.Themes.Fluent/Strings/InvariantResources.xaml
+++ b/src/Avalonia.Themes.Fluent/Strings/InvariantResources.xaml
@@ -25,5 +25,18 @@
{0} already exists. Do you want to replace it?
Yes
No
+ Scroll Here
+ Top
+ Bottom
+ Page Up
+ Page Down
+ Scroll Up
+ Scroll Down
+ Left Edge
+ Right Edge
+ Page Left
+ Page Right
+ Scroll Left
+ Scroll Right