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

38 lines
1,005 B
C#
Raw Permalink 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;
namespace MapControl.UiTools
2024-05-24 15:15:29 +02:00
{
public partial class MenuButton
2024-05-24 15:15:29 +02:00
{
public MenuButton()
2024-05-24 15:15:29 +02:00
{
var style = new Style();
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);
Flyout = new MenuFlyout();
Loaded += async (s, e) => await Initialize();
2024-05-24 15:15:29 +02:00
}
public string Icon
2024-05-24 15:15:29 +02:00
{
get => Content as string;
set => Content = value;
2024-05-24 15:15:29 +02:00
}
public MenuFlyout Menu => (MenuFlyout)Flyout;
2024-05-24 15:15:29 +02:00
[Content]
public ItemCollection Items => Menu.Items;
2024-05-24 15:15:29 +02:00
protected override Type StyleKeyOverride => typeof(Button);
2024-05-24 15:15:29 +02:00
}
}