FontWeight property doesn't work on TextBlock
hi, i have some issues with the FontWeight (and the FontStyle too) property ...
does anybody have those properties working ??
here is my code:
<TextBlock FontSize='12' TextWrapping='Wrap' Width='300' Height='Auto' Canvas.Left='10' Canvas.Top='55'><Run FontWeight="Bold">hello</Run></TextBlock>
thanks
Answers
The default font doesn't support anything other than normal weight and style. You need to specify a different font family such as Verdana. Also Height='auto' doesn't work/do anything and will probably be a parse error in newer bits. See this link for a list of supported fonts: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1056996&SiteID=1
If a font doesn't support a weight or style we currently (for v1) do not generate algorithmic bolded/italic versions of that font. This is why specifying Bold with the default font doesn't do anything.
-mark
Program Manager
Microsoft
This post is provided "as-is"
All Replies
Hi Wendy,
You can set the "FontWeight" property of the "TextBlock" element. Simply say
Code Snippet<TextBlock ... FontWeight="Bold" ... />Please refer to the Silverlight SDK for the TextBlock element for more information. The Silverlight SDK for the TextBlock element is available here: http://msdn2.microsoft.com/en-us/library/bb188394.aspx
If this answers your question, please select "Mark as Answer" otherwise, please post a followup question.
Thank you,
Chad Campbell
- i know but this doesn't work either... :-(
Hi Wendy,
I definately see you problem. I just attempted the following:
Code Snippet<
Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"><
TextBlock FontWeight="Normal" Text="Normal" /><
TextBlock Canvas.Top="20" FontWeight="ExtraBold" Text="Bold" /></
Canvas>
Unfortunately, it didn't work. It might be a bug in the current CTPGood point, Chad...
I went back and looked at some old code, because I could swear I'd used FontWeight, and I have FontWeight="900" on a few things that when I just changed it to "100", it didn't do anything. I'd like to think it did something when I wrote it, but at this point in time, it's hard telling.
At any rate, FontWeight doesn't appear to do anything now!
-Dave
The default font doesn't support anything other than normal weight and style. You need to specify a different font family such as Verdana. Also Height='auto' doesn't work/do anything and will probably be a parse error in newer bits. See this link for a list of supported fonts: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1056996&SiteID=1
If a font doesn't support a weight or style we currently (for v1) do not generate algorithmic bolded/italic versions of that font. This is why specifying Bold with the default font doesn't do anything.
-mark
Program Manager
Microsoft
This post is provided "as-is"
thanks for the answer, but i tried to use a FontFamily (Arial or Verdana) and it doesn't do anything...
<TextBlock FontFamily="Verdana" FontWeight="Bold" TextWrapping='Wrap' Width='300' Canvas.Left='10' Canvas.Top='55'>hello</TextBlock>
Hi Wendy...
Give this a shot:
<TextBlock FontFamily="Verdana" FontWeight="Bold" TextWrapping="Wrap" Canvas.Left="10" Canvas.Top="55" Text="hello" />
The Text= is inside the tag, and everything is double-quoted. I left off Width, I'm not sure it does anything in TextBlock.
Hope this helps!
-Dave
