how use icon [Font-awesome] in WPF

后端 未结 4 1777
谎友^
谎友^ 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:16

    To extend the accepted answer because it's somewhat out of date and missing information, here's what I did:

    • Download FontAwesome
    • Unzip the archive
    • Inside the unzipped folder, under the use-on-desktop folder, locate the version you want. N.B. Solid has the most icons free; some icons require a Pro payment for Regular and Light versions.
      • For me, this was Font Awesome 5 Free-Solid-900.otf.
    • Following the accepted answer and most tutorials, first create a sub-folder in your C# project named Fonts. Paste the fonts file inside this folder.
    • I renamed this file FontAwesome.otf for brevity
    • Set the properties of this file:
      • Build Action: Resource
      • Copy to Output Directory: Copy if newer/Copy always
    • In your App.xaml or other , insert:
    • /YOUR_PROJECT_NAME;component/Fonts/FontAwesome.otf#Font Awesome 5 Free Solid
      • Replace YOUR_PROJECT_NAME with your project name. I include this because it is needed should you use MergedDictionaries across projects.
      • If you did not place the file in a project sub-folder Fonts, rename or omit this part of the path.
      • Check that the filename matches: replace FontAwesome.otf with the filename (or rename the file itself).
      • Check the internal font name. You can do this by following the accepted answer. (Open the .otf or .tff file from explorer to start Windows Font Viewer, copy the font name).
      • Replace the Font Awesome 5 Free Solid with the font name (after the #).
      • Do not install the font otherwise you cannot verify that you have followed these steps correctly and the font may not work across computers that do not have the font installed.

提交回复
热议问题