在Windows Phone 8.0上使用c#的线性渐变画笔

时间:2015-11-07 10:09:59

标签: c# windows-phone-8

我在鼠标左键上创建了一个线性渐变。这是代码 我试图实现上面的线性渐变画笔

 private void r10_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            r10.Background = new LinearGradientBrush(Colors.Purple, Colors.Gray, 90);
        }

如果您有任何想法请帮助

1 个答案:

答案 0 :(得分:0)

您正在使用的构造函数在Silverlight中不存在。您可以这样重写代码:

var gradients = new GradientStopCollection
{
    new GradientStop {Color = Colors.Purple, Offset = 0},
    new GradientStop {Color = Colors.Gray, Offset = 1}
};

r10.Background.Background = new LinearGradientBrush(gradients, 90);