2025-03-21 17:22:07 +01:00
|
|
|
|
using System.Windows;
|
2022-01-11 19:42:12 +01:00
|
|
|
|
using System.Windows.Controls;
|
2025-03-21 17:22:07 +01:00
|
|
|
|
using System.Windows.Markup;
|
2022-01-11 19:42:12 +01:00
|
|
|
|
|
|
|
|
|
|
namespace MapControl.UiTools
|
|
|
|
|
|
{
|
2025-03-21 17:22:07 +01:00
|
|
|
|
[ContentProperty(nameof(Items))]
|
|
|
|
|
|
public partial class MenuButton
|
2022-01-11 19:42:12 +01:00
|
|
|
|
{
|
2022-01-24 23:07:36 +01:00
|
|
|
|
static MenuButton()
|
|
|
|
|
|
{
|
|
|
|
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(MenuButton), new FrameworkPropertyMetadata(typeof(MenuButton)));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-21 17:22:07 +01:00
|
|
|
|
public MenuButton()
|
2022-01-11 19:42:12 +01:00
|
|
|
|
{
|
2025-03-21 17:22:07 +01:00
|
|
|
|
ContextMenu = new ContextMenu();
|
|
|
|
|
|
DataContextChanged += (s, e) => ContextMenu.DataContext = e.NewValue;
|
|
|
|
|
|
Loaded += async (s, e) => await Initialize();
|
2022-01-11 19:42:12 +01:00
|
|
|
|
Click += (s, e) => ContextMenu.IsOpen = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-21 17:22:07 +01:00
|
|
|
|
public string Icon
|
2022-01-11 19:42:12 +01:00
|
|
|
|
{
|
2025-03-21 17:22:07 +01:00
|
|
|
|
get => Content as string;
|
|
|
|
|
|
set => Content = value;
|
2022-01-11 19:42:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-21 17:22:07 +01:00
|
|
|
|
public ContextMenu Menu => ContextMenu;
|
2022-01-11 19:42:12 +01:00
|
|
|
|
|
2025-03-21 17:22:07 +01:00
|
|
|
|
public ItemCollection Items => ContextMenu.Items;
|
2022-01-11 19:42:12 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|