How Set font family in C# wpf not in xaml

  • Thread starter Thread starter reza_jafery
  • Start date Start date
R

reza_jafery

Guest
Hi,first of all I am sorry for my language grammar because my first language is persian(Iran)

I added 2 custom font into my project at folder(folder name is Font Collection) by create folder then drag and drop font

I have no problem when I use XAML and this is my code FontFamily="Font Collection/Roboto.ttf#Roboto"

But at xaml.cs(C#) i want to change this font, for example Suppose in window load event i want change this

I cant change it i search link below

FontFamily Class (System.Windows.Media)

But it did not work

my code is

FontFamily = new FontFamily(new Uri(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "/Font Collection/")), "/#Bahij Uthman Taha");

Continue reading...
 
Back
Top