J'ai trouvé une grande énumération de la bibliothèque FontAwesome et je veux l'utiliser dans mon application WPF pour les icônes/images dans Textblocks. Le ENUM se présente comme suit:Enum valeur hexadécimale au texte textbloc
public enum Type
{
...
//ExclamationCircle, 0xf06A
ExclamationCircle = 0xf06A,
//ExclamationTriangle, 0xf071
ExclamationTriangle = 0xf071,
//Expand, 0xf065
Expand = 0xf065,
...
}
Je voudrais utiliser ce ENUM pour définir la valeur de mon Textblock donc je n'ai pas d'utiliser la valeur HEX à côté (0xf071 par exemple). Dans mon XAML, je donne les résultats suivants qui fonctionne comme je veux:
<TextBlock x:Name="tbIcon" FontFamily="{StaticResource FontAwesome}" Text="" Foreground="{StaticResource RedBrush}" FontSize="20" VerticalAlignment="Center" Margin="10" />
Quand j'ajoute le code suivant, je n'obtiens plus l'image mais le texte lui-même, je suis entré.
public DialogBase(string title, string message, Window owner)
{
InitializeComponent();
tbIcon.Text = FontAwesome.Type.ExclamationTriangle.AsHexString();
}
public static string AsHexString(this FontAwesome.Type type)
{
return String.Format(@"\u{0}", ((int)type).ToString("X").ToLower());
// This is returning "\uf071"
}
À long terme, je veux en faire une propriété publique d'un nouveau contrôle afin qu'il puisse être lié, mais je suis désireux d'obtenir cette étape de travail d'abord.