---
title: "WPF color effect for UI element"  
description: "WPF color effect for UI element"  
author: "Anonymous User"  
published: 2013-07-15  
updated: 2013-07-15  
canonical: https://www.mindstick.com/forum/1281/wpf-color-effect-for-ui-element  
category: "wpf"  
tags: ["wpf"]  
reading_time: 2 minutes  

---

# WPF color effect for UI element

Hello [Mindstick](https://yourviews.mindstick.com/view/84668/how-mindstick-is-used-for-marketing-purposes)! \

How do I [add](https://www.mindstick.com/forum/12983/add-address-in-textbox-when-page-is-load-and-if-i-search-address-in-textbox-show-in-map-by-javascript) a [color](https://www.mindstick.com/articles/77/how-to-split-form-background-color-in-c-sharp) [effect](https://yourviews.mindstick.com/view/81363/coronavirus-effect-on-american-farms-is-severe) to a UI element? \

For example, it should look more yellow, so pixels have a more yellow color. All I need is to make my [black](https://yourviews.mindstick.com/view/83102/badi-elaichi-black-cardamom-health-benefits) [form](https://www.mindstick.com/forum/6/multi-form-mfc-application) a [bit](https://www.mindstick.com/forum/33411/how-we-tell-programmatically-if-i-m-running-in-64-bit-jvm-or-32-bit-jvm) white, while it is inactive.

Thanks in Advance.\

## Replies

### Reply by shreesh chandra shukla

I recently needed a gradient effect that would go from a specified color to a lighter version of that color. I came across this [post](http://social.msdn.microsoft.com/Forums/vstudio/en-US/26a68ffd-bd51-4a72-8eda-d1dcff556f1d/make-color-lighter) which works very nicely.

Here is the code as an extension method

```
public static Color Interpolate(this Color color1, Color color2, float percentage)
    {
        double a1 = color1.A / 255.0, r1 = color1.R / 255.0, g1 = color1.G / 255.0, b1 = color1.B / 255.0;
        double a2 = color2.A / 255.0, r2 = color2.R / 255.0, g2 = color2.G / 255.0, b2 = color2.B / 255.0;
        byte a3 = Convert.ToByte((a1 + (a2 - a1) * percentage) * 255);
        byte r3 = Convert.ToByte((r1 + (r2 - r1) * percentage) * 255);
        byte g3 = Convert.ToByte((g1 + (g2 - g1) * percentage) * 255);
        byte b3 = Convert.ToByte((b1 + (b2 - b1) * percentage) * 255);
        return Color.FromArgb(a3, r3, g3, b3);
    }   
```

In my case I mix in 50 % white\

```
BackgroundColor.Interpolate(Colors.White, .5f);
```


---

Original Source: https://www.mindstick.com/forum/1281/wpf-color-effect-for-ui-element

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
