I want to add a few basic properties to an image. I would normally do this by doing
public class ExtendedImage: Image
{
}
But ofcourse this isn’t allowed because it’s sealed.
What other ways can I do this? The reason I want to extend Image, is because I’m looking to dynamically create and destroy objects, which get dragged and dropped around the application. So I want to add manipulation handlers, and gestures, as well as adding and removing the object from various display objects.
I don’t believe I’m able to inject an instance of Image into my base class, because then the data and the image will be decoupled when I try to have my dynamically created images respond to various manipulation events etc. (Based on the location the image is placed on in the main canvas, I need it to have different functionality.
Any advice on this issue is greatly appreciated.
You could use the Tag property to associate instances and get the kind of behavior you desire. Something like: