tags:

views:

37

answers:

2

I have a WrapPanel where I add a bunch of rectangle controls I got everything working, but now I have decided that it would be better to create a class for them and instead of creating rectangles all over the place I'll just instantiate new objects.

I did it but the problem is that now I get an error when I try to add my object as a Child to the WrapPanel or anywhere for that matter.

Error: The best overloaded method match for 'System.Windows.PresentationFrameworkCollection.Add(System.Windows.UIElement)' has some invalid arguments

I tried extending my class with the UIElement class

 public class myColor : UIElement {...}

this didn't work either as I'm missing the constructors for the UIElement class Error:

The type 'System.Windows.UIElement' has no constructors defined

I'm still learning Silverlight and c#, any help would be appreciated it, Thanks

A: 

I don't believe the UIElement class can be extended. You could use extension methods or you could try inheriting from a FrameworkElement.

Eclipsed4utoo
+2  A: 

Silverlight does not allow you to inherit UIElement as it is possible in WPF. You can inherit from FrameworkElement or take it one step further and inherit from Control.

Jakob Christensen