我在App.xaml中为Label定义了样式。无法覆盖WPF中的标签样式
<Application.Resources>
<ResourceDictionary>
<Style TargetType="Label" >
<Setter Property="Foreground" Value="Blue"/>
</Style>
<Style TargetType="TextBlock" >
<Setter Property="Foreground" Value="Blue"/>
</Style>
</ResourceDictionary>
</Application.Resources>
适用于我的MainWindow.xaml中的标签Control的样式。但是当我试图在控件上明确设置Foreground时,它不起作用(我想知道)。 App.xaml中定义的颜色仍然适用(仅用于标签)。
<Grid>
<Label Content="Label" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Text="TextBlock" Foreground="Black" VerticalAlignment="Bottom" Height="15.96" Margin="257.537,0,270.003,86" />
</Grid>
相同的逻辑适用于Textblock和所有控件。有什么建议吗?
绝对正确。谢谢...:) – Jawahar 2011-01-12 06:14:16