using System.Windows.Markup; using WPFluent.Controls; namespace WPFluent.Markup; /// /// SymbolIcon which can provide . /// /// /// /// <ui:Button /// Appearance="Primary" /// Content="WPF UI button with font icon" /// /// Icon="{ui:SymbolIcon Symbol=Fluent24}" /> /// /// <ui:Button Icon="{ui:SymbolIcon /// Fluent24}" /> /// /// <ui:HyperlinkButton Icon="{ui:SymbolIcon Fluent24}" /> /// /// /// <ui:TitleBar Icon="{ui:SymbolIcon Fluent24}" /> /// /// [ContentProperty(nameof(Symbol))] [MarkupExtensionReturnType(typeof(SymbolIcon))] public class SymbolIconExtension : MarkupExtension { public SymbolIconExtension() { } public SymbolIconExtension(SymbolRegular symbol) { Symbol = symbol; } public SymbolIconExtension(string symbol) { Symbol = (SymbolRegular)Enum.Parse(typeof(SymbolRegular), symbol); } public SymbolIconExtension(SymbolRegular symbol, bool filled) : this(symbol) { Filled = filled; } public override object ProvideValue(IServiceProvider serviceProvider) { SymbolIcon symbolIcon = new(Symbol, filled: Filled); if (FontSize > 0) { symbolIcon.FontSize = FontSize; } return symbolIcon; } [ConstructorArgument("filled")] public bool Filled { get; set; } public double FontSize { get; set; } [ConstructorArgument("symbol")] public SymbolRegular Symbol { get; set; } }