mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
34 lines
899 B
C#
34 lines
899 B
C#
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Markup;
|
|
|
|
namespace MapControl.UiTools
|
|
{
|
|
[ContentProperty(nameof(Items))]
|
|
public partial class MenuButton
|
|
{
|
|
static MenuButton()
|
|
{
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(MenuButton), new FrameworkPropertyMetadata(typeof(MenuButton)));
|
|
}
|
|
|
|
public MenuButton()
|
|
{
|
|
ContextMenu = new ContextMenu();
|
|
DataContextChanged += (s, e) => ContextMenu.DataContext = e.NewValue;
|
|
Loaded += async (s, e) => await Initialize();
|
|
Click += (s, e) => ContextMenu.IsOpen = true;
|
|
}
|
|
|
|
public string Icon
|
|
{
|
|
get => Content as string;
|
|
set => Content = value;
|
|
}
|
|
|
|
public ContextMenu Menu => ContextMenu;
|
|
|
|
public ItemCollection Items => ContextMenu.Items;
|
|
}
|
|
}
|