I have a default TextBlock style defined in App.xaml, which seems to also affect the text color of ComboBox items. Now, how do I explicitly set the text color of a ComboBox defined in my main window? (I'd like to keep the default style, but have the combobox text color as, say, blue instead of red...)
App.xaml
<Application x:Class="WpfApplication1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<Style TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="Red" />
</Style>
</Application.Resources>
MainWindow.xaml
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow">
<Grid>
<ComboBox Name="comboBox1" SelectedIndex="0" HorizontalAlignment="Left" VerticalAlignment="Top">
<ComboBoxItem Content = "Item1"/>
<ComboBoxItem Content = "Item2"/>
<ComboBoxItem Content = "Item3"/>
</ComboBox>
</Grid>
Things I've tried:
- Set Combobox.Foreground
- Set TextElement.Foreground
- Set TextBlock.Foreground
- Define another implicit TextBlock style in ComboBox.Resources
- Define another implicit TextBlock style in Grid.Resources
- Define another implicit TextBlock style in Window.Resources