【发布时间】:2010-05-24 01:59:02
【问题描述】:
我在尝试将我们的大型项目升级到 SL4 时遇到错误。
我没有写原始主题,我的主题知识也不是很好。
在我的演示应用程序中,我有一个 Label 和一个 LabelHeader(我已经创建了它,它只是 Label 的派生类,带有 DefaultStyleKey = typeof(LabelHeader);
我正在为 LabelHeader 设置样式:
<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>
这在 SL3 中有效,但在 SL4 中我得到:
错误:Silverlight 应用程序中未处理的错误
代码:2500
类别:ParserError
消息:在“System.Windows.Controls.Control”类型中找不到属性“内容”。
文件:
线路:9
位置:168
如果我改变这个: 内容="{模板绑定内容}" 到 内容="XXX" 然后就没有错误了,但是,当然,我在我的标签中得到了XXX,而不是我在页面上的XAML中设置的内容
有什么想法可以让这个工作吗?
这里是演示项目:
http://walkersretreat.co.nz/files/ThemeIssue.zip
(抱歉转帖,我这里暂时没有答案:http://forums.silverlight.net/forums/p/183380/415930.aspx#415930)
编辑提供的答案看起来会起作用。此处已针对此问题打开了一个问题: https://connect.microsoft.com/VisualStudio/feedback/details/561183
如果您认为这很重要,请投票!
【问题讨论】:
标签: silverlight silverlight-4.0 themes