Implicit theme error:The property 'Content' was not found in type 'System.Windows.Controls.Control'.

Posted by Mark on Stack Overflow See other posts from Stack Overflow or by Mark
Published on 2010-05-24T01:59:02Z Indexed on 2010/05/24 2:00 UTC
Read the original article Hit count: 496

I have got an error while trying to upgrade our large project to SL4. I didn't write the original theme and my theme knowlege isn't great. In my demo app I have a Label and a LabelHeader(which i have created and is just a derived class from Label with DefaultStyleKey = typeof(LabelHeader);
I am styling lthem like this:

 <Style TargetType="themeControls:LabelHeader">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <DataInput:Label 
                    FontSize="{TemplateBinding FontSize}" 
                    FontFamily="{TemplateBinding FontFamily}" 
                    Foreground="{TemplateBinding Foreground}" 
                    Content="{TemplateBinding  Content}"/>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
    <Setter Property="FontFamily" Value="Tahoma"/>
    <Setter Property="FontSize" Value="20"/>
    <Setter Property="Foreground" Value="Red"/>
</Style>

This works in SL3 but in SL4 I get:

Error: Unhandled Error in Silverlight Application Code: 2500
Category: ParserError
Message: The property 'Content' was not found in type 'System.Windows.Controls.Control'.
File:
Line: 9
Position: 168

If I change this: Content="{TemplateBinding Content}" to Content="XXX" Then there is no error but , of course, I get XXX in my label rather than the content I set in XAML on the page

Any ideas how I can get this working?

Demo project here:

http://walkersretreat.co.nz/files/ThemeIssue.zip

(Apologies for reposting, I have so far got no answers over here: http://forums.silverlight.net/forums/p/183380/415930.aspx#415930)

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about silverlight-4.0