The typical way to handle this is to just have a handler for each container. That won't work if you are dynamically creating them (I'm assuming you mean you create them via code at runtime). So, what comes to mind is to create a class for the handler. It would have properties for any items you need access to in the handler and a public methods for the handlers (one for BodyHidden and one for BodyRestore).
public class ContainerImageSwitcher
{
/// <summary>
/// Require that a ThemedContainer be provided in constructor.
/// </summary>
public ContainerImageSwitcher(ThemedContainer container)
{
this.Container = container;
}
public property ThemedContainer Container { get; set;}
public void HandleHidden() { //-- show image, using this.Container }
public void HandleRestore() { //-- hide image, using this.Container }
}
Now in your code that creates the ThemedContainers and sets the handlers you can use the class:
private ThemedContainer BuildContainer()
{
ThemedContainer newContainer = new ThemedContainer();
//-- Setup as appropriate....
//-- Add handlers
ContainerImageSwitcher switcher = new ContainerImageSwitcher(newContainer);
newContainer.BodyHidden += switcher.HandleHidden;
newContainer.BodyRestore += switcher.HandleRestore;
//-- Return container
return newContainer;
}
I haven't tested this, but it should work.