Creating a script to change the button color

Hello!
There was a question when using the script: I have 4 buttons with text. It is necessary that when you click on the first button, the color of the button and the text changes, and the other three are painted in a completely different color. An example of a script I’m trying to use:
rectangle32 .background = new dundas.controls.SolidColorBrush (new dundas.controls.Color (0xFFFFFF));
label5.fontColor = new dundas.controls.SolidColorBrush (new dundas.controls.Color (0x000F0A));
rectangle33 .background = new dundas.controls.SolidColorBrush (new dundas.controls.Color (0x646464));
label6.fontColor = new dundas.controls.SolidColorBrush (new dundas.controls.Color (0xFFFFFF));
rectangle34 .background = new dundas.controls.SolidColorBrush (new dundas.controls.Color (0x646464));
label7.fontColor = new dundas.controls.SolidColorBrush (new dundas.controls.Color (0xFFFFFF));
rectangle35 .background = new dundas.controls.SolidColorBrush (new dundas.controls.Color (0x646464));
label8.fontColor = new dundas.controls.SolidColorBrush (new dundas.controls.Color (0xFFFFFF));

Everything works, but after a while the dashboard breaks down and cannot be restored.
Error code:Error 1 of 1
Title:
The request is invalid.
Details:
Web response code: Bad Request: (undefined)
Thank you in advance!

We used to run into that and were told the following

When using a script to change the fill of an object use:
brush = new dundas.controls.SolidColorBrush('xxxxxxx')

if you are changing the font colour of an object use:
dundas.controls.Color.fromString("xxxxxxxxx")

Otherwise it breaks the dashboard as you described.

3 Likes

Hey Denis,
maybe you can use the menu control instead of 4 buttons and achieve this without script? I use the menu control for example to create a navigation menu and it does what you describe. You would create a menu control with 4 elements and style them so they look like your buttons (it is quite flexible that way). Then you can configure the active style and the non active style the way you need it. So when a user selects menu item 1 it becomes active and looks a certain ways and the three others take on the non active style. Below is an example of a menu I built that looks like 3 buttons. The active state adds the line at the top but you can also change color and more.
image

3 Likes

Thank you very much. Both councils solved the problem.