wpf controls - how use icon [Font-awesome] in WPF -
i new in wpf. want use font-awesome icon in textbox , button. icon not bind textbox
i install font-awesome resource application.
let me know way how can use it
thank you,
i need please me..
step 1 : download font-awesome
tools -> library package manager -> package manager console install
pm > install-package fontawesome.wpf
step 2 : add resource
<application> xmlns:fa="http://schemas.fontawesome.io/icons/" </application>
step 3 : put app.xaml
<application.resources> <style x:key="fontawesome"> <setter property="textelement.fontfamily" value="pack://application:,,,/fonts/#fontawesome" /> </style> </application.resources>
step 4 : use in demo.xaml
<textblock style="{staticresource fontawesome}" fontsize="75" text="" />
step 5 :- output
first, download font awesome, extract zip file , copy fonts/fontawesome-webfont.ttf
fonts folder in solution. set build action in properties resource if isn’t already
next, add style resources in app.xaml
. don’t forget #
@ front of font name , remember use internal name of font, not name of file. check name of font, double click on font file , open in windows font viewer. font name @ top.
<application.resources> <fontfamily x:key="fontawesome">/fonts/fontawesome-webfont.ttf#fontawesome</fontfamily> </application.resources>
open mainwindow.xaml
, replace grid below snippet:
<grid verticalalignment="center" horizontalalignment="center"> <stackpanel orientation="horizontal" > <textblock text="i" fontsize="32" margin="10" verticalalignment="center"></textblock> <textblock x:name="tbfontawesome" text="" fontfamily="{staticresource fontawesome}" foreground="red" fontsize="32" margin="10" verticalalignment="center"></textblock> <textblock text="font awesome" fontsize="32" margin="10" verticalalignment="center"></textblock> </stackpanel> </grid>
notice "text"
property of "tbfontawesome"
textblock, unicode
heart
.
Comments
Post a Comment