Skip to content

Commit

Permalink
Fixed the markup extension for the SymbolIcon and FontIcon class not …
Browse files Browse the repository at this point in the history
…working at all.
  • Loading branch information
m0lDaViA committed Apr 22, 2024
1 parent d88b815 commit d33ecf3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
22 changes: 12 additions & 10 deletions src/Wpf.Ui/Markup/FontIconExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,31 @@ namespace Wpf.Ui.Markup;
[MarkupExtensionReturnType(typeof(FontIcon))]
public class FontIconExtension : MarkupExtension
{
public FontIconExtension(string glyph)
public FontIconExtension()
{
Glyph = glyph;
FontFamily = new FontFamily("FluentSystemIcons");
}

public FontIconExtension(string glyph, FontFamily fontFamily)
: this(glyph)
public FontIconExtension(string glyph)
{
FontFamily = fontFamily;
Glyph = glyph;
}

[ConstructorArgument("glyph")]
public string Glyph { get; set; }
public string? Glyph { get; set; }

[ConstructorArgument("fontFamily")]
public FontFamily FontFamily { get; set; }
public FontFamily FontFamily { get; set; } = new("FluentSystemIcons");

public double FontSize { get; set; }

public override object ProvideValue(IServiceProvider serviceProvider)
{
var fontIcon = new FontIcon { Glyph = Glyph, FontFamily = FontFamily };
if (serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget { TargetObject: Setter })
{
return this;
}

FontIcon fontIcon = new() { Glyph = Glyph, FontFamily = FontFamily };

Check warning on line 59 in src/Wpf.Ui/Markup/FontIconExtension.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference assignment.

if (FontSize > 0)
{
Expand All @@ -63,4 +65,4 @@ public override object ProvideValue(IServiceProvider serviceProvider)

return fontIcon;
}
}
}
12 changes: 11 additions & 1 deletion src/Wpf.Ui/Markup/SymbolIconExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ namespace Wpf.Ui.Markup;
[MarkupExtensionReturnType(typeof(SymbolIcon))]
public class SymbolIconExtension : MarkupExtension
{

Check warning on line 34 in src/Wpf.Ui/Markup/SymbolIconExtension.cs

View workflow job for this annotation

GitHub Actions / build


public SymbolIconExtension()
{
}

public SymbolIconExtension(SymbolRegular symbol)
{
Symbol = symbol;
Expand All @@ -58,7 +63,12 @@ public SymbolIconExtension(SymbolRegular symbol, bool filled)

public override object ProvideValue(IServiceProvider serviceProvider)
{
var symbolIcon = new SymbolIcon { Symbol = Symbol, Filled = Filled };
if (serviceProvider.GetService(typeof(IProvideValueTarget)) is IProvideValueTarget { TargetObject: Setter })
{
return this;
}

SymbolIcon symbolIcon = new() { Symbol = Symbol, Filled = Filled };

if (FontSize > 0)
{
Expand Down

0 comments on commit d33ecf3

Please sign in to comment.