0

need to write musical symbols to my C# WPF application. Found Symbola font, that contains them and can write the symbols in XAML. But I need to add them frome code behinde. - For importing font to my app I used https://stackoverflow.com/a/39912794/10985932 - In XAML I can write symbols to TextBlock or Label by this:

<TextBlock x:Name="myTextBlock" Text="&#x1d11a;" FontFamily="{StaticResource Symbola}" FontSize="50.0" FontStyle="Normal" FontWeight="Regular"/> <Label x:Name="lab" Content="&#x1d11a;" FontFamily="{StaticResource Symbola}" FontSize="50"></Label>

But don't know how to change Text or Content from code behinde. Tried to search, hoping using Application.Current.Resources["Symbola"] could help, but dont know how to access concrete "char" in this font. Thanks for any help.

Ilona
  • 3
  • 2

2 Answers2

0

Access the controls by name in the code behind and then set the Text property for the Textblock and the Content property for the Label

myTextBlock.Text = "\U0001D11A";
lab.Content = "\U0001D111";
Wes
  • 386
  • 1
  • 7
  • Problem is, that symbols I need to display have more than 16bits code :-/ – Ilona Jan 29 '19 at 19:32
  • I've updated my answer to to use an eight digit `\U` literal. Ref https://stackoverflow.com/questions/20934250/unicode-character-u1fxyz-not-outputting-correctly-when-used-in-code-behind – Wes Jan 29 '19 at 20:12
  • Thank you very much, Wes :-) Don't know how I could miss so many good answers for my question. Now I see many of them, just ask wrong before – Ilona Jan 29 '19 at 20:24
0

Tried some other idea and found solution here How to convert emoticons to its UTF-32/escaped unicode? in ckuris comment. Used Char.ConvertFromUtf32(0x1d11a)and that's what I needed

Ilona
  • 3
  • 2