1

There was already a post on this but appeared there was no resolution. Perhaps it was before the SelectionBrush property was exposed for the TextBox.

I have a Style for the TextBox in my resources that works correctly (the selected text is not the default System color but a color I have chosen). I would assume the TextBox component of my custom ComboBox template would use that TextBox Style but the selected text in the ComboBox TextBox is still blue.

Since I know I can control the selected text color of a TextBox, how do I control it in my ComboBox ControlTemplate? I have image and code exaqmples but this forum will not let me post them since this is my first time.

Mxyk
  • 10,678
  • 16
  • 57
  • 76
Palikea
  • 21
  • 4
  • Try this: [How to customize selection brush for each TextBox in your app](http://stackoverflow.com/a/34381625/3135228) – Pollitzer Dec 22 '15 at 15:42

2 Answers2

1

You can use the below code, it solve your problem

<Window.Resources>
        <Style TargetType="{x:Type TextBox}">
            <Setter Property="SelectionBrush" Value="Yellow"></Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <TextBox Text="ramesh test" Margin="67,12,184,240" />
        <ComboBox ItemsSource="{Binding}" Name="testCombo" Margin="67,48,184,204">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                   <TextBox  Text="mytext" Width="100" Height="50" />
                </DataTemplate>
            </ComboBox.ItemTemplate>            
        </ComboBox>
    </Grid>
Smaug
  • 2,625
  • 5
  • 28
  • 44
0

You can override the ComboBox HighlightBrushKey color

    <ComboBox x:Name="MyCombo" ItemsSource="{Binding Items}" Margin="0,0,0,148">
        <ComboBox.Resources>
            <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Yellow" />
        </ComboBox.Resources>
    </ComboBox>
sa_ddam213
  • 42,848
  • 7
  • 101
  • 110