mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 14:08:32 +00:00
MapMenuItem
This commit is contained in:
parent
616b2bf3f7
commit
3f16d1d637
10 changed files with 54 additions and 82 deletions
|
|
@ -1,6 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
#if UWP
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Media;
|
||||
|
|
@ -13,34 +12,15 @@ namespace MapControl.UiTools
|
|||
{
|
||||
public abstract partial class MapMenuItem : ToggleMenuFlyoutItem
|
||||
{
|
||||
public abstract bool GetIsChecked(MapBase map);
|
||||
|
||||
public abstract Task ExecuteAsync(MapBase map);
|
||||
|
||||
protected MapMenuItem()
|
||||
{
|
||||
Loaded += (s, e) =>
|
||||
{
|
||||
ParentMenuItems = ((Panel)VisualTreeHelper.GetParent(this)).Children.OfType<MapMenuItem>().ToList();
|
||||
|
||||
if (DataContext is MapBase map)
|
||||
{
|
||||
IsChecked = GetIsChecked(map);
|
||||
}
|
||||
Initialize();
|
||||
};
|
||||
|
||||
Click += async (s, e) =>
|
||||
{
|
||||
if (DataContext is MapBase map)
|
||||
{
|
||||
await ExecuteAsync(map);
|
||||
|
||||
foreach (var item in ParentMenuItems)
|
||||
{
|
||||
item.IsChecked = item.GetIsChecked(map);
|
||||
}
|
||||
}
|
||||
};
|
||||
Click += (s, e) => Execute();
|
||||
}
|
||||
|
||||
protected IList<MapMenuItem> ParentMenuItems { get; private set; }
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
<DefineConstants>WINUI</DefineConstants>
|
||||
<RootNamespace>MapControl.UiTools</RootNamespace>
|
||||
<AssemblyTitle>XAML Map Control UI Tools Library for WinUI</AssemblyTitle>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue