1
嗯,我想我在想念這裏的東西..觸發器不能按假設工作?
任何方式我嘗試做一個Metro風格的WPF主題,所以我就開始用這樣的:
<Color x:Key="PrimaryColor">#8CBF26</Color>
<Color x:Key="TextColor">White</Color>
<Color x:Key="BackgroundColor">Black</Color>
<SolidColorBrush x:Key="PrimaryBrush" Color="{StaticResource ResourceKey=PrimaryColor}" />
<SolidColorBrush x:Key="ForgroundBrush" Color="{StaticResource ResourceKey=TextColor}" />
<SolidColorBrush x:Key="BackgroundBrush" Color="{StaticResource ResourceKey=BackgroundColor}" />
<FontFamily x:Key="FontFamily">Segoe WP, Segoe UI, Lucida Sans Unicode, Verdana</FontFamily>
<Style TargetType="{x:Type Window}">
<Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
</Style>
<Style TargetType="{x:Type Run}">
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontFamily" Value="{StaticResource FontFamily}" />
<Setter Property="Foreground" Value="{StaticResource ForgroundBrush}" />
</Style>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontFamily" Value="{StaticResource FontFamily}" />
<Setter Property="Foreground" Value="{StaticResource ForgroundBrush}" />
</Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Background" Value="{StaticResource BackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{StaticResource ForgroundBrush}"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="Foreground" Value="{StaticResource ForgroundBrush}"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Padding" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" >
<ContentPresenter Margin="{TemplateBinding Padding}" RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Background" Value="{StaticResource ForgroundBrush}" />
<Setter Property="Foreground" Value="{StaticResource BackgroundBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
嗯,這對所有的偉大工程,但觸發Foreground屬性永遠不會被修改,我的猜測是已經設置了TextBlock的樣式,所以它不能覆蓋它的forecolor是否有任何解決此問題的解決方法?
感謝
在按鈕的樣式中,我定義了前景和背景...樣式被應用,但是當我點擊按鈕時前景顏色沒有改變... – Peter
@Petoj:好吧,正如我所說的那樣爲我做。我只是將所有這些複製到一些資源中,創建了一個按鈕,當按下時背景變成白色,前景變成黑色。 –
我完全困惑,我想生病嘗試創建一個虛擬項目,並嘗試在那裏! – Peter