Search code examples
c#colorsbrush

compare a brush and color


if (backBrush == SystemColors.ActiveCaption)

This fails. Says you can't compare a brush and a color.

How do I find the color of the brush?


Solution

  • If backBrush is a SolidColorBrush (based on what you're trying to do it probably is) you can use:

    if(((SolidColorBrush)backBrush).Color == SystemColors.ActiveCaption)