Search code examples
dundas

How to change the color of a button in Dundas Dashboard v 2.5 on Click


How can we change the Color of a button in Dundas Dashboard v 2.5 on Click. I know that we have On Click interaction and we have to assign the Fill Property.

How do we do it using say a Linear Gradient Brush.

Thanks for your suggestions in Advance!


Solution

  • There are 2 ways to get a Linear Gradient Brush that you can set the Fill property to.

    1) If you need it to be truly dynamic, build the brush from the ground up using script. For instance:

    DashboardLinearGradientBrush b = new DashboardLinearGradientBrush();
    b.StartPoint = new Point (0,0);
    b.EndPoint = new Point(0,1);
    
    DashboardGradientStop stop = new DashboardGradientStop(Colors.Black, 0);
    b.GradientStops.Add(stop);
    
    stop = new DashboardGradientStop(Colors.White, 1.0);
    b.GradientStops.Add(stop);
    
    Button1.Fill = b;
    

    2) If you're just switching between some predefined colors, create a Rectangle shape outside the dashboard canvas and set up the brush on the rectangle. Then, when you want to switch the color, you can do something like this in the On Click interaction:

    Button1.Fill = Rectangle1.Fill;