12
我有2 Label
s在StackPanel
和Foreground
颜色设置为他们两个... 第二个显示为黑色,当它不应该。WPF标签前景色
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Grid.Column="4" Grid.Row="0" Width="Auto" Margin="0,0,20,0">
<Label Content="{lex:LocText CGI, Suffix=:}" Foreground="#FFE0E0E0" FontSize="24" VerticalAlignment="Bottom" Margin="0,0,0,10" HorizontalAlignment="Right" />
<Label Content="{Binding Cgi}" ContentStringFormat="{}{0}%" Foreground="#FFE0E0E0" FontSize="24" VerticalAlignment="Bottom" Margin="0,0,0,10" HorizontalAlignment="Right" />
</StackPanel>
有什么我做错了吗?
您的猜测是正确的。我注意到这种行为,因为我们添加了Metro风格。没想到这一点。 – JuHwon
仅仅因为我搜索了如何更改标签的颜色,并且将它带到了这里,我想补充一点,如果您只是想在代码文件中更改标签的颜色,则应该这样做:'lblStatus.Foreground =新的SolidColorBrush(Colors.Red);' – Ortund
或少一点代码,'lblStatus.Foreground = Brushes.Red;' –