Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Silverlight 2 Beta 2 Property Value Inheritance bug?
4 replies. Latest Post by splace on September 26, 2008.
(0)
splace
Member
20 points
19 Posts
06-10-2008 6:22 PM |
According to WPF/Silverlight (at least I think this is the way it is suppose to work). When figuring out what value a property has
1) Local value
2) Style setters
3) Property Value Inheritance (up the element tree)
4) Default value
In WPF their are other precedences eg. template triggers.. etc...
Silverlight seems to put Property Value Inheritance ahead of Styles as demonstrated in the snippet below. The FontSize property is controlled by the setting on the UserControl and not from the Style definition.
<UserControl x:Class="TextBlockWithStyleStarter.Test" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300" FontSize="24"> <Grid x:Name="LayoutRoot" Background="White"> <Grid.Resources> <Style TargetType="TextBlock" x:Key="TextBlockPrompt"> <Setter Property="FontSize" Value="10" /> </Style> </Grid.Resources> <TextBlock Style="{StaticResource TextBlockPrompt}" Text="Hello Silverlight" /> </Grid></UserControl>
Is this a bug? Or have I misinterpreted something wrong here? I think the Style would be a better choice IMO.
Regards,
Sandy
Jim Mangaly
Contributor
2622 points
381 Posts
06-11-2008 12:21 AM |
You are right, I would think it should work the way you expect. That is how WPF works: http://msdn.microsoft.com/en-us/library/ms743230.aspx#listing.
Interesting the documentation for Silverlight does not mention Property Value Inheritance in the DP Value Precedence list: http://msdn.microsoft.com/en-us/library/cc265148(VS.95).aspx#listing. Property Value Inheritance ,I understand, was added in Beta 2, and I guess they forgot to update the documentation with it?
Is this a bug?
Hope this helps,Jim (http://jimmangaly.blogspot.com/)
Please MARK the replies as answers if they answered your question
Dave Relyea
Participant
1084 points
249 Posts
06-11-2008 12:23 AM |
Yeah, it is a bug.
06-11-2008 11:28 AM |
That is unfortunate as it does compromise your design decisions. I can see this having huge ramifications down the line, if people decide to work around the bug, or worse take advantage of this behavior a lot of UI's are going to suddenly break when this gets fixed. I realize It is beta after all but the with the go live license and all the hype it seems a hotfix for some of these high priority issues might be considered. I hope I am not trying to blow this issue out of proportion.
Thanks for confirming anyways,
09-26-2008 12:30 PM |
This has now been fixed in RC0..
Great work and thank you.