mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-07 15:36:20 +00:00
New menu item implementation based directly on MenuItem/ToggleMenuFlyoutItem
This commit is contained in:
parent
11cd45c099
commit
e06dcc5155
12 changed files with 335 additions and 412 deletions
50
MapUiTools/Shared/MenuButton.cs
Normal file
50
MapUiTools/Shared/MenuButton.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using System.Threading.Tasks;
|
||||
#if WPF
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
#elif UWP
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
#elif WINUI
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
#else
|
||||
using Avalonia.Controls;
|
||||
using DependencyProperty = Avalonia.AvaloniaProperty;
|
||||
#endif
|
||||
|
||||
namespace MapControl.UiTools
|
||||
{
|
||||
public partial class MenuButton : Button
|
||||
{
|
||||
public static readonly DependencyProperty MapProperty =
|
||||
DependencyPropertyHelper.Register<MenuButton, MapBase>(nameof(Map), null,
|
||||
async (button, oldValue, newValue) => await button.Initialize());
|
||||
|
||||
public MapBase Map
|
||||
{
|
||||
get => (MapBase)GetValue(MapProperty);
|
||||
set => SetValue(MapProperty, value);
|
||||
}
|
||||
|
||||
private async Task Initialize()
|
||||
{
|
||||
if (Map != null)
|
||||
{
|
||||
DataContext = Map;
|
||||
|
||||
if (Items.Count > 0)
|
||||
{
|
||||
if (Items[0] is MapLayerMenuItem mapLayerItem)
|
||||
{
|
||||
await mapLayerItem.Execute(Map);
|
||||
}
|
||||
else if (Items[0] is MapProjectionMenuItem mapProjectionItem)
|
||||
{
|
||||
mapProjectionItem.Execute(Map);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue