Hi @ll,
first: our basics
- wpf application with implicit styles
- user is allowed to change the theme on the fly
Now I want to use different foreground colors of a TextBlock
to illustrate a special meaning. Therefore I use the following style:
<
Style
TargetType
=
"{x:Type TextBlock}"
x:Key
=
"CompareStatusStyle"
>
<
Style.Triggers
>
<
DataTrigger
Binding
=
"{Binding Status}"
Value
=
"{x:Static vm:CompareStatus.Different}"
>
<
Setter
Property
=
"Foreground"
Value
=
"Orange"
/>
</
DataTrigger
>
<
DataTrigger
Binding
=
"{Binding Status}"
Value
=
"{x:Static vm:CompareStatus.OnlyA}"
>
<
Setter
Property
=
"Foreground"
Value
=
"Red"
/>
</
DataTrigger
>
<
DataTrigger
Binding
=
"{Binding Status}"
Value
=
"{x:Static vm:CompareStatus.OnlyB}"
>
<
Setter
Property
=
"Foreground"
Value
=
"ForestGreen"
/>
</
DataTrigger
>
<
DataTrigger
Binding
=
"{Binding Status}"
Value
=
"{x:Static vm:CompareStatus.Unknown}"
>
<
Setter
Property
=
"Foreground"
Value
=
"Gray"
/>
</
DataTrigger
>
</
Style.Triggers
>
</
Style
>
This works mostly very well.
But when I used this Style inside a RadTreeView (header) there are some
problems with background colors. (see the attached image)
My question: what is the best way to define colors which might be change
using a different theme or adapt automatically to the background.
I found a bad way: using code behind to change the background color
of the SelectionVisual of a RadTreeViewItem. But unfortunately not every
theme is build in the same way and the border defining the background
color is not in path from my content to the RadTreeItem, so finding the
current background color is hard.
Has anyone an idea how I can solve this?
Thanks a lot.
Best regards
Christian