日期:2014-05-18 浏览次数:22091 次
Rectangle rect = new Rectangle();
rect.VerticalAlignment = VerticalAlignment.Top;
rect.Height = 1;
rect.Width = 300;
rect.Height = 300;
// 几种方式 你看下
rect.Fill = Brushes.Red;
rect.Fill = new SolidColorBrush() { Color = Colors.Red, Opacity = 0.8 };
rect.SetValue(Rectangle.FillProperty, Brushes.Olive);
rect.Fill = new LinearGradientBrush()
{
StartPoint = new Point(0, 0),
EndPoint = new Point(0, 1),
GradientStops = new GradientStopCollection()
{
new GradientStop(Colors.Red, 0),
new GradientStop(Colors.Blue, 1)
}
};
Grid.SetRow(rect, 1);
LayoutRoot.Children.Add(rect);