Skip to content

Commit

Permalink
Fix menu separator regression
Browse files Browse the repository at this point in the history
  • Loading branch information
timschneeb committed Feb 3, 2024
1 parent 00e9eb5 commit 0245863
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions GalaxyBudsClient/Utils/MenuFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Interactivity;

namespace GalaxyBudsClient.Utils
Expand All @@ -12,15 +13,15 @@ public static class MenuFactory

public static ContextMenu BuildContextMenu(Dictionary<string, EventHandler<RoutedEventArgs>?> content, Control? placementTarget = null, bool embedSeparators = true)
{
var menu = new ContextMenu {PlacementMode = PlacementMode.Bottom, PlacementTarget = placementTarget};
var menu = new ContextMenu {Placement = PlacementMode.BottomEdgeAlignedLeft, PlacementTarget = placementTarget};
menu.Classes.Add(MenuStyle);
menu.ItemsSource = BuildMenu(content, embedSeparators);
return menu;
}

public static List<MenuItem> BuildMenu(Dictionary<string, EventHandler<RoutedEventArgs>?> content, bool embedSeparators = true)
public static List<TemplatedControl> BuildMenu(Dictionary<string, EventHandler<RoutedEventArgs>?> content, bool embedSeparators = true)
{
var items = new List<MenuItem>();
var items = new List<TemplatedControl>();
foreach(KeyValuePair<string, EventHandler<RoutedEventArgs>?> entry in content)
{
items.Add(BuildMenuItem(entry.Key, entry.Value));
Expand All @@ -44,9 +45,11 @@ public static MenuItem BuildMenuItem(string header, EventHandler<RoutedEventArgs
return item;
}

public static MenuItem BuildSeparator()
public static Separator BuildSeparator()
{
return BuildMenuItem("-");
var sep = new Separator();
sep.Classes.Add(MenuStyle);
return sep;
}
}
}

0 comments on commit 0245863

Please sign in to comment.