Skip to main content

Microsoft Silverlight

Answered Question Silverlight 2 Beta 2 Property Value Inheritance bug?RSS Feed

(0)

splace
splace

Member

Member

20 points

19 Posts

Silverlight 2 Beta 2 Property Value Inheritance bug?

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
Jim Mangaly

Contributor

Contributor

2622 points

381 Posts

Re: Silverlight 2 Beta 2 Property Value Inheritance bug?

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

http://www.identitymine.com/

Dave Relyea
Dave Relyea

Participant

Participant

1084 points

249 Posts

Microsoft
Answered Question

Re: Re: Silverlight 2 Beta 2 Property Value Inheritance bug?

Yeah, it is a bug.

splace
splace

Member

Member

20 points

19 Posts

Re: Re: Re: Silverlight 2 Beta 2 Property Value Inheritance bug?

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,

Sandy 

splace
splace

Member

Member

20 points

19 Posts

Re: Re: Re: Silverlight 2 Beta 2 Property Value Inheritance bug?

This has now been fixed in RC0..

 

Great work and thank you.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities