mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
47 lines
1.2 KiB
C#
47 lines
1.2 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
namespace MapControl.UiTools
|
|
{
|
|
public class MenuButton : Button
|
|
{
|
|
static MenuButton()
|
|
{
|
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(MenuButton), new FrameworkPropertyMetadata(typeof(MenuButton)));
|
|
}
|
|
|
|
protected MenuButton(string icon)
|
|
{
|
|
Content = icon;
|
|
|
|
Click += (s, e) => ContextMenu.IsOpen = true;
|
|
}
|
|
|
|
protected ContextMenu CreateMenu()
|
|
{
|
|
var menu = new ContextMenu();
|
|
ContextMenu = menu;
|
|
return menu;
|
|
}
|
|
|
|
protected IEnumerable<MenuItem> GetMenuItems()
|
|
{
|
|
return ContextMenu.Items.OfType<MenuItem>();
|
|
}
|
|
|
|
protected static MenuItem CreateMenuItem(string text, object item, RoutedEventHandler click)
|
|
{
|
|
var menuItem = new MenuItem { Header = text, Tag = item };
|
|
menuItem.Click += click;
|
|
return menuItem;
|
|
}
|
|
|
|
protected static Separator CreateSeparator()
|
|
{
|
|
return new Separator();
|
|
}
|
|
}
|
|
}
|