Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set color as Window's highlight color?

As title, how?

I want to make a TextBlock when got focused, it background color will be window os's highlighted color (i.e The color when you highlight text in your internet explorer).

Is there any way I can get that color code so I can put into the style?

<Trigger Property="IsFocused" Value="True">
    <Setter Property="FontWeight" Value="Bold" />
    <Setter Property="Background" Value="Blue"/>
    <Setter Property="Foreground" Value="White"/>
</Trigger>
like image 348
King Chan Avatar asked Mar 03 '12 19:03

King Chan


1 Answers

I am a little confused on what exactly you are asking for. The selected Background color or the selected Text color, and are you wanting WPF or Silverlight. This will will give you the Highlight background brush in WPF.

Look at the SystemColors Class specifically the SystemColors.HighlightBrush Property

<Setter Property="Background" Value="{x:Static SystemColors.HighlightBrush}" />

As for Silverlight take a look at this SO question

like image 193
Mark Hall Avatar answered Nov 10 '22 21:11

Mark Hall