Displaying Colors as a Background from a Hex Value on a spreadsheet.

Posts: 11
I'd like to know how I could go about having a dynamic background fill on a label that is being read from a corresponding hex value that is on a linked spreadsheet?
Posts: 785
For now you'll need a small script to convert the color string (e.g. hex) to an actual color. I have some plans to automate that in a next version but that isn't working yet. Add a new C# script and copy the code from below.

The rest is simple: add your spreadsheet to the theme, go to your label and find the Overrides category, then find the Override Background Color property. Choose your spreadsheet column that has the hex color as your data binding. Then choose the script as the converter script.

using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using System.Windows.Media;

namespace Scripts
{
public class StringToColorConverter : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
var colorString = value?.ToString();
if (string.IsNullOrWhiteSpace(colorString))
return Colors.Transparent;

return (Color)ColorConverter.ConvertFromString(colorString);
}
}
}