how use icon [Font-awesome] in WPF

后端 未结 4 1789
谎友^
谎友^ 2020-12-25 12:41

I am new in WPF. I want to use Font-awesome Icon in textbox and button. but the icon is not bind with my textbox

I install Font-awesome resource to my application.<

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-25 13:19

    First, download Font Awesome, extract the ZIP file and copy fonts/fontawesome-webfont.ttf into a Fonts folder in your solution. Set the Build Action in the properties to Resource if it isn’t already

    Next, add a Style to the Resources in App.xaml. Don’t forget the # at the front of the font name and remember to use the internal name of the font, not the name of the file. To check the name of the font, just double click on the font file and it will open in the Windows Font Viewer. The font name will be at the top.

    
    /Fonts/fontawesome-webfont.ttf#FontAwesome
    
    

    Open MainWindow.xaml and replace the grid with below snippet:

    
    
    
    
    
    
    
    
    
    
    
    
    
    

    Notice "Text" property of "tbFontAwesome" textblock, its the Unicode for Heart.

    Cheat Sheet

提交回复
热议问题