Answered by:
Whats wrong with my style?

Question
-
Im getting a compile error "Error 6 '12' is not a valid value for the 'System.Windows.Documents.TextElement.FontSize'" when I apply my style to a label. It "looks right", I could use someone elses opinion what is wrong:
<Window x:Class="MoneyClient.RevisedScreen" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:net="clr-namespace:System;assembly=mscorlib" Title="Revised Screen" Height="480" Width="600"> <Window.Resources> <net:Int32 x:Key="titleFontSize">12</net:Int32> <Style x:Key="headerStyle" TargetType="Label"> <Setter Property="FontSize" Value="{StaticResource titleFontSize}" /> <Setter Property="FontWeight" Value="Bold" /> </Style> </Window.Resources> <Label Content="Setup" FontSize="12" FontWeight="Bold" Style="{StaticResource headerStyle}"/> </Window>
Thnx
Mat
Tuesday, September 7, 2010 7:12 PM
Answers
-
The issue is that FontSize on a Label control isn't actually an Int32, it is a double.
- Marked as answer by Matt Raffel Wednesday, September 8, 2010 10:30 AM
Tuesday, September 7, 2010 7:25 PM
All replies
-
The issue is that FontSize on a Label control isn't actually an Int32, it is a double.
- Marked as answer by Matt Raffel Wednesday, September 8, 2010 10:30 AM
Tuesday, September 7, 2010 7:25 PM -
Thank you. and in silverlight 2 I think its an int32, as I was looking a silverlight 2 implementation I did :) lol.Wednesday, September 8, 2010 10:30 AM
-
Would've been better to say how to easily specify that the number is a double. Had to go to another site, since I didn't want to have to declare another variable.
headerStyle.SetValue(Setter.FontSizeProperty, 12D);
I believe would be the equivalent here, if setting it in code-behind (which would be far simpler than that ugly binding property!).
- Proposed as answer by navyjax2 Monday, September 12, 2016 6:45 PM
Monday, September 12, 2016 6:45 PM