<Style targettype="{x:Type TextBlock}"> <Setter Property="margin" Value="10,10,10" /></Style>
为属性targettype提供错误无效属性值{x:Type TextBlock}.
我从MSDN复制并粘贴了这一位,所以我有点迷失为什么我收到这个错误.
编辑:
这是我现在正在尝试的完整代码:
<UserControl x:Class="NIRC.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WIDth="400" Height="300"> <UserControl.Resources> <Style targettype="TextBlock"> <Setter Property="margin" Value="10" /> <Setter Property="Foreground" Value="Red" /> </Style> </UserControl.Resources> <TextBlock>Hello World!</TextBlock></UserControl>
这是它的外观:
alt text http://www.netortech.com/Content/slhw.jpg
解决方法 Silverlight不支持通过通用样式的隐式样式(即使用targettype但没有静态资源键 – x:Key =“”)但WPF却支持.您需要在要使用Style =“{StaticResource stylename}”设置样式的元素的每个实例上使用StaticResource引用显式应用样式.
Silverlight toolkit有一个隐式样式管理器(ISM),它通过包装Silverlight标记并通过解析内容从ResourceDictionarIEs应用样式来解决这个问题.
总结以上是内存溢出为你收集整理的.net – Silverlight:TargetType的属性类型无效=“{x:Type TextBlock}”全部内容,希望文章能够帮你解决.net – Silverlight:TargetType的属性类型无效=“{x:Type TextBlock}”所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)