Hi, I've been using Children.Add with different default silverlight controls adding them to canvases. What I don't get is why something like this is possible:
Rectangle rec = new Rectangle(){...};
canvas.Children.Add(rec);
but not something like this (doesn't even compile):
myRectangle rec = new myRectangle();
canvas.Children.Add(rec);
myRectangle being just a wrapper to a rectangle
I'm sure I'm missing something fundamental.. Thanks for any help.
myRectangle class:
public class myRectangle
{
private SolidColorBrush fillColor;
private Rectangle recNewColor;
internal myRectangle()
{
fillColor = new SolidColorBrush(Colors.White);
LinearGradientBrush strokeBrush = new LinearGradientBrush()
{
StartPoint = new Point(0.5, 0),
EndPoint = new Point(0.5, 1),
GradientStops =
{
new GradientStop() { Color = Colors.Red, Offset = 1.0 },
new GradientStop() { Color = Colors.Orange, Offset = 0.0 },
}
};
recNewColor = new Rectangle()
{
Stroke = strokeBrush,
Height = 20,
Width = 20,
Fill = fillColor,
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Top,
Margin = new Thickness() { Bottom = 5, Left = 5 },
};
}
...
}