Brush[] brushes = new Brush[3];
SolidColorBrush scb = new new SolidColorBrush();
scb.Color = Colors.Blue;
brushes[0] = scb;

LinearGradientBrush lgb = new LinearGradientBrush();
lgb.StartPoint = new Point(0,0);
lgb.EndPoint = new Point(0.8, 1.5);
GradientStop gs = new GradientStop();
gs.Offset = 0;
gs.Color = Colors.Green;
lgb.GradientStops.Add(gs);
gs = new GradientStop();
gs.Offset = 1;
gs.Color = Colors.Cyan;
lgb.GradientStops.Add(gs);
brushes[1] = lgb;

lgb = new LinearGradientBrush();
lgb.StartPoint = new Point(0,0);
lgb.EndPoint = new Point(0, 1);
gs = new GradientStop();
gs.Offset = 0;
gs.Color = Colors.Black;
lgb.GradientStops.Add(gs);
gs = new GradientStop();
gs.Offset = 1;
gs.Color = Colors.Red;
lgb.GradientStops.Add(gs);
brushes[2] = lgb;

myGrid.Resources["brushes"] = brushes;
...
myListBox.ItemsSource = myListBox.Resources["brushes"];

