WPF 后台赋值iconfont,实现图标的切换

WPF 后台赋值iconfont

<TextBlock
                    x:Name="txtMessageIcon"
                    Margin="10,0,0,0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    FontFamily="/XXX;component/WPF/Resources/Fonts/#iconfont"
                    Text="&#xe7e7;"
                    TextAlignment="Center" />

在这里插入图片描述
其中 “& #xe7e7;’”是Unicode编码
在C#后台中赋值则需要这样写:

txtTest.Text = “\xe7e7”;

实际测试如下所示:
在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_41883890/article/details/129262850