XAML-Map-Control/MapUiTools/Avalonia/MenuButton.Avalonia.cs

37 lines
915 B
C#
Raw Normal View History

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