Have you ever used a resource in the Visual tree of a control just to hold a data object which you can access later in an Item Template.

For example:

<Grid>
    <Grid.Resources>
        <ContentControl x:Key="BindingContent" Content="{Binding}" />
    </Grid.Resources>
    <ListBox>
        <ListBox.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding MyProperty}"
                           Foreground="{Binding Path=Content.MyProperty2,
                           Source={StaticResource BindingContent}}" />
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
</Grid>

In this example, the Textblock has a foreground bound to a data object residing in a resource. Everything works fine in the above example and runs as expected in Silverlight 4.

In Silverlight 5, this “workaround” just stops working. This is due to a bug fix in Silverlight 5.

More details at Silverlight 5 Incompatibility: Play by the Rules by Jeremy Likness.

Share your thoughts