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;' –