2025-02-27 18:46:32 +01:00
|
|
|
|
using Avalonia;
|
2024-05-24 15:15:29 +02:00
|
|
|
|
using Avalonia.Controls;
|
|
|
|
|
|
using Avalonia.Media;
|
2025-03-21 17:22:07 +01:00
|
|
|
|
using Avalonia.Metadata;
|
2024-05-24 15:15:29 +02:00
|
|
|
|
using Avalonia.Styling;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
2025-03-21 17:22:07 +01:00
|
|
|
|
namespace MapControl.UiTools
|
2024-05-24 15:15:29 +02:00
|
|
|
|
{
|
2025-03-21 17:22:07 +01:00
|
|
|
|
public partial class MenuButton
|
2024-05-24 15:15:29 +02:00
|
|
|
|
{
|
2025-03-21 17:22:07 +01:00
|
|
|
|
public MenuButton()
|
2024-05-24 15:15:29 +02:00
|
|
|
|
{
|
|
|
|
|
|
var style = new Style();
|
2025-03-21 17:22:07 +01:00
|
|
|
|
style.Setters.Add(new Setter(TextBlock.FontFamilyProperty, new FontFamily("Segoe MDL2 Assets")));
|
2024-05-24 15:15:29 +02:00
|
|
|
|
style.Setters.Add(new Setter(TextBlock.FontSizeProperty, 20d));
|
|
|
|
|
|
style.Setters.Add(new Setter(PaddingProperty, new Thickness(8)));
|
|
|
|
|
|
Styles.Add(style);
|
|
|
|
|
|
|
2025-03-21 17:22:07 +01:00
|
|
|
|
Flyout = new MenuFlyout();
|
|
|
|
|
|
Loaded += async (s, e) => await Initialize();
|
2024-05-24 15:15:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-21 17:22:07 +01:00
|
|
|
|
public string Icon
|
2024-05-24 15:15:29 +02:00
|
|
|
|
{
|
2025-03-21 17:22:07 +01:00
|
|
|
|
get => Content as string;
|
|
|
|
|
|
set => Content = value;
|
2024-05-24 15:15:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-21 17:22:07 +01:00
|
|
|
|
public MenuFlyout Menu => (MenuFlyout)Flyout;
|
2024-05-24 15:15:29 +02:00
|
|
|
|
|
2025-03-21 17:22:07 +01:00
|
|
|
|
[Content]
|
|
|
|
|
|
public ItemCollection Items => Menu.Items;
|
2024-05-24 15:15:29 +02:00
|
|
|
|
|
2025-03-21 17:22:07 +01:00
|
|
|
|
protected override Type StyleKeyOverride => typeof(Button);
|
2024-05-24 15:15:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|