# Change color through binding expressions

**URL:** <https://forum.inductiveautomation.com/t/change-color-through-binding-expressions/31444>\
**Category:** Ignition\
**Created:** [January 20, 2020, 10:02pm UTC](https://forum.inductiveautomation.com/t/change-color-through-binding-expressions/31444 "2020-01-20T22:02:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gzarate](https://avatars.discourse-cdn.com/v4/letter/g/ba8739/32.png) [@gzarate](https://forum.inductiveautomation.com/u/gzarate)\
**Post date:** [January 20, 2020, 10:02pm UTC](https://forum.inductiveautomation.com/t/change-color-through-binding-expressions/31444/1 "2020-01-20T22:02:27Z")

</div>

I want to change the color of an object through a binding expression  
it is possible?

I was thinking in a code like this

if({Close\_Tag}&&!{Open\_Tag})= true  
{New Template.Rectangle 1.fillPaint} = color (255,0,0,[0])

but this doesn’t must be my sintax I’ll appreciate the help

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [January 20, 2020, 10:21pm UTC](https://forum.inductiveautomation.com/t/change-color-through-binding-expressions/31444/2 "2020-01-20T22:21:38Z")

</div>

Yes, the syntax was a bit off. See [if - Ignition User Manual 8.0 - Ignition Documentation](https://docs.inductiveautomation.com/display/DOC80/if). The required syntax is `if(condition, trueReturn, falseReturn)`. Note the closing parenthesis for the if statement comes after everything else, not after `condition`. You don’t need “= true”, and the `if` expression requires values to return for both true and false, with condition and the two returns separated by commas. It returns the value that will be bound to the property you put the binding on; you don’t reference the property in the binding.

Put this in `New Template.Rectangle 1.fillPaint` expression binding (don’t include `New Template.Rectangle 1.fillPaint` in the expression):

```java
if({Close_Tag} && !{Open_Tag},
	// Use this color when true.
	color (255,0,0,0),
	// Use this color when false
	color (255,0,0,0)
)

```

P.S. Make posted code easy to read by enclosing it in triple back ticks ``` on a line above and below–or use the preformatted text button: ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/1/108a3c826e8fd2db7454c00dbc5f7ece2fe26d2b.png)

---

<div class="post-metadata">

**Author:** ![gzarate](https://avatars.discourse-cdn.com/v4/letter/g/ba8739/32.png) [@gzarate](https://forum.inductiveautomation.com/u/gzarate)\
**Post date:** [January 20, 2020, 11:15pm UTC](https://forum.inductiveautomation.com/t/change-color-through-binding-expressions/31444/3 "2020-01-20T23:15:04Z")

</div>

Thanks man that work perfect.
