UWP use FontIcon

Original: UWP use FontIcon

Usually in the Settings button content, we generally write the text, for example,

<Button Content="OK"/>

 

 

But there are some special circumstances, such as we need a button icon,

 

 

This time it requires some special operations.

        <Button>
            <FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xF5B0;" FontSize="30" />
        </Button>

 

Since Xaml can achieve, you can also clatter in .cs file.

FontIcon fi = new FontIcon();
fi.FontFamily = new Windows.UI.Xaml.Media.FontFamily("Candara");
fi.Glyph = "\uF5B0";
Button.Icon=fi;

 

 

Noticed yet, in the xaml,

Glyph="&#xF5B0;"

In the .cs

fi.Glyph = "\uF5B0";

 

 

 

参考:using FontIcon Glyph from code (C#)

 

Guess you like

Origin www.cnblogs.com/lonelyxmas/p/12094876.html
UWP