문제가 있습니다.mainWindow에서 linearGradientBrush 메서드를 호출하는 방법은 무엇입니까?
내가LinearGradientBrush
에 XAML에서 내 방법 (MainWindow를)를 호출하고 싶은
- 그래서 내가 애니메이션 배경의 색상을 변경하려면>GradientStop
. 코드 XAML에서
public static List<Color> GetGradientColors(Color start, Color end, int steps)
{
return GetGradientColors(start, end, steps, 0, steps - 1);
}
public static List<Color> GetGradientColors(Color start, Color end, int steps, int firstStep, int lastStep)
{
var colorList = new List<Color>();
if (steps <= 0 || firstStep < 0 || lastStep > steps - 1)
return colorList;
double aStep = (end.A - start.A)/steps;
double rStep = (end.R - start.R)/steps;
double gStep = (end.G - start.G)/steps;
double bStep = (end.B - start.B)/steps;
for (int i = firstStep; i < lastStep; i++)
{
byte a = (byte)(start.A + (int)(aStep * i));
byte r = (byte)(start.R + (int)(rStep * i));
byte g = (byte)(start.G + (int)(gStep * i));
byte b = (byte)(start.B + (int)(bStep * i));
colorList.Add(Color.FromArgb(a, r, g, b));
}
return colorList;
}
:
<LinearGradientBrush StartPoint="0.0, 0.6" EndPoint="1.0, 0.6">
<GradientStop Color="{ Binding GetGradientColors(green, yellow, 2)}" Offset="0"/>
</LinearGradientBrush>
는이 작업을 수행하는 것이 가능 I은 여러 매개 변수가있는 기능이?
왜 그렇게하려고? 그라디언트 브러시는 자체적으로 보간하기 만하면 '녹색'에 대해 한 번 정지하고 '황색'에 대해 하나씩 중지해야합니다. –