How to change font style and font weight programmatically using c# in metro app for windows 8.1
Asked Answered
I

2

8

I want to change FontStyle and FontWeight using c# in my code .

I tried this:

textblock.FontStyle =FontStyle.Normal 

and

textblock.FontWeight =FontWeight.Bold 

but its not working.

Inlaid answered 21/5, 2014 at 8:53 Comment(0)
C
16

I'd not recommend to do that in code, but if it is necessary:

textblock.FontStyle = Windows.UI.Text.FontStyle.Italic;
textblock.FontWeight = Windows.UI.Text.FontWeights.Bold;
Ceaseless answered 21/5, 2014 at 13:35 Comment(3)
Sounds like that's what the OP tried (though they must have had a using statement for Windows.UI.Text).Delanos
Sure, you are right. The code works, just double checked it. If the using statement is there we need more info/code.Ceaseless
thanks I was doing this mistake textblock.FontStyle = new Windows.UI.Text.FontStyle.Italic;Inlaid
T
0

Try:

FontWeight = FontWeights.Bold

class: System.Windows.FontWeight

Info from: [https://learn.microsoft.com/en-us/dotnet/api/system.windows.controls.textblock.fontweight?view=windowsdesktop-8.0]

Typology answered 17/6, 2024 at 17:31 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.