TextBlock 的样式(如下)对 DataTemplate 的 TextBlock 没有影响。如果我在样式和模板中将 TextBlock 更改为 TextBox,则样式将按我的预期应用。为什么 TextBlock 会忽略样式?
谢谢你,
Ben
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:l="clr-namespace:SilverlightApplication1" mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<UserControl.Resources>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="20" />
</Style>
<Style TargetType="TextBox">
<Setter Property="FontSize" Value="20" />
</Style>
<DataTemplate DataType="l:MyObject">
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</UserControl.Resources>
<StackPanel>
<ItemsControl>
<ItemsControl.Items>
<l:MyObject Name="Frank" />
</ItemsControl.Items>
</ItemsControl>
</StackPanel>
</UserControl>
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)