0

I'm trying to create a method in C#, that uses colors.

public void Layoutgenerator(Color ColorA, Color ColorB)
    {
        LinearGradientBrush lgb = new LinearGradientBrush();
        lgb.StartPoint = new Point(0, 0);
        lgb.EndPoint = new Point(1, 1);
        lgb.GradientStops.Add(new GradientStop(Colors.ColorA, 0.0));
        lgb.GradientStops.Add(new GradientStop(Colors.ColorB, 1.0));
        this.Background = lgb;
    }

But unfortunately it's not working. This is the error message: "System.Windows.Media.Colors" does not contain a definition for "ColorB".

Does someone know my fallacy?

I want to call it this way: Layoutgenerator(WhiteSmoke, LightGray);

sjantke
  • 605
  • 4
  • 9
  • 35

1 Answers1

1

ColorA and ColorB are already colors, so

lgb.GradientStops.Add(new GradientStop(ColorA, 0.0));
lgb.GradientStops.Add(new GradientStop(ColorB, 1.0));

should do the trick. You'll have to call the method using:

Layoutgenerator(Colors.WhiteSmoke, Colors.LightGray);
C.Evenhuis
  • 25,996
  • 2
  • 58
  • 72