When WPF using UWP, Could we set Microsoft.UI.Xaml.Media.FontFamily by C# code?

GuoLearn 251 Reputation points
2021-09-03T01:31:34.143+00:00

this XAML can set fontFamily :
<FontFamily>fontFamilyName[,fallbackFontFamilyName]*</FontFamily>

  • or -
    <object FontFamily="fontFamilyName[,fallbackFontFamilyName]" ... />
    -or-
    <object FontFamily="[uri]fontFamilyName[,[uri]fallbackFontFamilyName]
    " ... />
    -or-
    <object FontFamily="embeddedUri#fontFamilyName[,[uri]fallbackFontFamilyName]*" ... />

Can we set the fontFamily by C# code ,like
FontFamily= new FontFamily(new Uri(@"C:\fontFamilyName").AbsoluteUri) ?
i try it but it do not work。
Could you tell me the right way to do it and The "embeddedUri#fontFamilyName" could you make me a example?

Developer technologies | Windows Presentation Foundation
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.