mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-07 23:45:05 +00:00
MapMenuItem
This commit is contained in:
parent
616b2bf3f7
commit
3f16d1d637
10 changed files with 54 additions and 82 deletions
|
|
@ -1,38 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace MapControl.UiTools
|
||||
{
|
||||
public abstract partial class MapMenuItem : MenuItem
|
||||
public partial class MapMenuItem : MenuItem
|
||||
{
|
||||
public abstract bool GetIsChecked(MapBase map);
|
||||
|
||||
public abstract Task ExecuteAsync(MapBase map);
|
||||
|
||||
protected MapMenuItem()
|
||||
{
|
||||
Loaded += (s, e) =>
|
||||
{
|
||||
if (DataContext is MapBase map)
|
||||
{
|
||||
IsChecked = GetIsChecked(map);
|
||||
}
|
||||
};
|
||||
|
||||
Click += async (s, e) =>
|
||||
{
|
||||
if (DataContext is MapBase map)
|
||||
{
|
||||
await ExecuteAsync(map);
|
||||
|
||||
foreach (var item in ParentMenuItems)
|
||||
{
|
||||
item.IsChecked = item.GetIsChecked(map);
|
||||
}
|
||||
}
|
||||
};
|
||||
Loaded += (s, e) => Initialize();
|
||||
Click += (s, e) => Execute();
|
||||
}
|
||||
|
||||
public string Text
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net9.0-windows;net462</TargetFrameworks>
|
||||
<LangVersion Condition="'$(TargetFramework)'=='net462'">8.0</LangVersion>
|
||||
<LangVersion Condition="'$(TargetFramework)'=='net462'">12.0</LangVersion>
|
||||
<UseWPF>true</UseWPF>
|
||||
<DefineConstants>WPF</DefineConstants>
|
||||
<RootNamespace>MapControl.UiTools</RootNamespace>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue