-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaterialIconExt.cs
38 lines (28 loc) · 919 Bytes
/
MaterialIconExt.cs
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
using System;
using Microsoft.UI.Xaml.Markup;
using Material.Icons;
using Microsoft.UI.Xaml;
namespace Material.Icons.UNO;
[MarkupExtensionReturnType(ReturnType = typeof(MaterialIcon))]
public class MaterialIconExt : MarkupExtension {
public MaterialIconExt() { }
public MaterialIconExt(MaterialIconKind kind) {
Kind = kind;
}
public MaterialIconExt(MaterialIconKind kind, double size) {
Kind = kind;
Size = size;
}
// [ConstructorArgument("kind")]
public MaterialIconKind Kind { get; set; }
// [ConstructorArgument("size")]
public double? Size { get; set; }
protected override object ProvideValue(IXamlServiceProvider serviceProvider) {
var result = new MaterialIcon { Kind = Kind };
if (Size.HasValue) {
result.Height = Size.Value;
result.Width = Size.Value;
}
return result;
}
}