2017-08-21 71 views
-2

1-創建一個新的WPF應用程序。如何使所有控件的前景色默認爲白色

2-將一些控件添加到您的WPF應用程序。

3-查看默認情況下所有控件的前景色爲黑色。

如何使所有控件的前景色默認爲白色?

enter image description here

+0

對於某些控件,它足以使他們的父母'的前景色窗口「,但我不確定它是否適用於_every_控件。 – nondestructive

回答

2

「默認情況下,所有控件的前景色爲黑色。」因爲它是Windows主題設置。

您可以指定使用自己的前景刷ControlTextBrushKey關鍵

<Application.Resources> 
    <SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey }" Color="Green"/> 
</Application.Resources> 

該設置將立即看到設計師在屬性網格

0

你可以嘗試在你的窗口的XAML或App.xaml定義的隱含TextBox風格:

<Window x:Class="WpfApplication1.MainWindow" 
     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:local="clr-namespace:WpfApplication1" 
     mc:Ignorable="d" 
     Title="MainWindow" Height="300" Width="300"> 
    <Window.Resources> 
     <Style TargetType="TextBlock"> 
      <Setter Property="Foreground" Value="White" /> 
     </Style> 
    </Window.Resources> 
... 

這可能是你能設置的所有控件的文本顏色在一個地方最接近。

+2

那麼,你可以停止看,因爲沒有這樣的設置。 VS中的設計器中的設置不會更改控件的依賴項屬性的默認值。 – mm8

相關問題