mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-06 15:05:50 +00:00
Version 7.1.0: Added MapUiTools
This commit is contained in:
parent
731158c22d
commit
2ac4985c47
37 changed files with 437 additions and 463 deletions
47
MapUiTools/WPF/MenuButton.WPF.cs
Normal file
47
MapUiTools/WPF/MenuButton.WPF.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2022 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace MapControl.UiTools
|
||||
{
|
||||
public class MenuButton : Button
|
||||
{
|
||||
protected MenuButton(string icon)
|
||||
{
|
||||
FontFamily = new FontFamily("Segoe MDL2 Assets");
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue