Updated MenuButton

This commit is contained in:
Clemens 2022-01-24 23:07:36 +01:00
parent b921600e1b
commit 69fd0753f7
7 changed files with 26 additions and 15 deletions

View file

@ -0,0 +1,3 @@
using System.Windows;
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]

View file

@ -6,15 +6,18 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace MapControl.UiTools
{
public class MenuButton : Button
{
static MenuButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(MenuButton), new FrameworkPropertyMetadata(typeof(MenuButton)));
}
protected MenuButton(string icon)
{
FontFamily = new FontFamily("Segoe MDL2 Assets");
Content = icon;
Click += (s, e) => ContextMenu.IsOpen = true;

View file

@ -0,0 +1,11 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tools="clr-namespace:MapControl.UiTools">
<Style TargetType="tools:MenuButton" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="FontFamily" Value="Segoe MDL2 Assets"/>
<Setter Property="FontSize" Value="20"/>
<Setter Property="Padding" Value="8"/>
</Style>
</ResourceDictionary>

View file

@ -7,11 +7,9 @@ using System.Linq;
#if WINUI
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Media;
#elif UWP
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
#endif
namespace MapControl.UiTools
@ -20,11 +18,7 @@ namespace MapControl.UiTools
{
protected MenuButton(string icon)
{
Content = new FontIcon
{
FontFamily = new FontFamily("Segoe Fluent Icons"),
Glyph = icon
};
Content = new FontIcon { Glyph = icon };
}
protected MenuFlyout CreateMenu()