using System.Windows.Markup;
using WPFluent.Controls;
namespace WPFluent.Markup;
///
/// Custom which can provide .
///
///
/// /// <ui:Button /// Appearance="Primary" /// Content="WPF UI button with font icon" ///
/// Icon="{ui:FontIcon '🌈'}" /> /// /// <ui:Button Icon="{ui:FontIcon
/// '🌈'}" /> /// /// <ui:HyperlinkButton Icon="{ui:FontIcon '🌈'}"
/// /> /// /// <ui:TitleBar Icon="{ui:FontIcon '🌈'}" /> ///
///
[ContentProperty(nameof(Glyph))]
[MarkupExtensionReturnType(typeof(FontIcon))]
public class FontIconExtension : MarkupExtension
{
public FontIconExtension()
{
}
public FontIconExtension(string glyph) { Glyph = glyph; }
public override object ProvideValue(IServiceProvider serviceProvider)
{
FontIcon fontIcon = new() { Glyph = Glyph!, FontFamily = FontFamily };
if (FontSize > 0)
{
fontIcon.FontSize = FontSize;
}
return fontIcon;
}
[ConstructorArgument("fontFamily")]
public FontFamily FontFamily { get; set; } = new("FluentSystemIcons");
public double FontSize { get; set; }
[ConstructorArgument("glyph")]
public string? Glyph { get; set; }
}