-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathSymbolIconExtension.cs
More file actions
43 lines (37 loc) · 1.28 KB
/
SymbolIconExtension.cs
File metadata and controls
43 lines (37 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
namespace CommunityToolkit.WinUI;
/// <summary>
/// Custom <see cref="MarkupExtension"/> which can provide symbol-based <see cref="FontIcon"/> values.
/// </summary>
[MarkupExtensionReturnType(ReturnType = typeof(FontIcon))]
public partial class SymbolIconExtension : TextIconExtension
{
/// <summary>
/// Gets or sets the <see cref="Symbol"/> value representing the icon to display.
/// </summary>
public Symbol Symbol { get; set; }
/// <inheritdoc/>
protected override object ProvideValue()
{
var fontIcon = new FontIcon
{
Glyph = unchecked((char)Symbol).ToString(),
FontFamily = SymbolThemeFontFamily,
FontWeight = FontWeight,
FontStyle = FontStyle,
IsTextScaleFactorEnabled = IsTextScaleFactorEnabled,
MirroredWhenRightToLeft = MirroredWhenRightToLeft
};
if (FontSize > 0)
{
fontIcon.FontSize = FontSize;
}
if (Foreground != null)
{
fontIcon.Foreground = Foreground;
}
return fontIcon;
}
}