XAML-Map-Control/MapUiTools/WPF/MenuButton.WPF.cs

34 lines
899 B
C#
Raw Permalink Normal View History

using System.Windows;
2022-01-11 19:42:12 +01:00
using System.Windows.Controls;
using System.Windows.Markup;
2022-01-11 19:42:12 +01:00
namespace MapControl.UiTools
{
[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)));
}
public MenuButton()
2022-01-11 19:42:12 +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;
}
public string Icon
2022-01-11 19:42:12 +01:00
{
get => Content as string;
set => Content = value;
2022-01-11 19:42:12 +01:00
}
public ContextMenu Menu => ContextMenu;
2022-01-11 19:42:12 +01:00
public ItemCollection Items => ContextMenu.Items;
2022-01-11 19:42:12 +01:00
}
}