How to change label border color on button click?

Hi,

I would like to change the color of the border of a label on button click. I’ve tried to assign a SolidBrush object to the color property, however, it did not change color.

Am I missing out on something?

var newColor = new dundas.controls.SolidColorBrush("Red");
label1.border.color = newColor;

Regards,

Renzi

The sub-properties of border aren’t tracked when they are changed, so changing the color property to a new brush is not sufficient.

You can create a new border and assign it, although re-assigning the existing one should also work after you’ve updated a property on it:

label1.border = label1.border;

I was just looking at this when Terrence replied and I thought I’d also point out that the .color part of the border uses dundas.controls.Color and not dundas.controls.SolidColorBrush.

I see thank you for your replies. I will try it out.