ThemedContainer BodyHiddenEventHandler question


Author
Message
Keith Chisarik
Keith Chisarik
StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
I have a form on which I dynamically create X number of ThemedContainer controls, I add a handler for the BodyHidden event on creation of the control but the delegate BodyHiddenEventHandler does not  have a signature that includes sender. When the events fires I dont know which themedcontainer was collapsed.

I want to show the TitleImage when the body is collapsed and hide it when it is expanded. How can I accomplish this?



Keith Chisarik
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
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.

Keith Chisarik
Keith Chisarik
StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)StrataFrame VIP (1.5K reputation)
Group: StrataFrame Users
Posts: 939, Visits: 40K
Yes, they are created via code at runtime. I will try your suggestion, thanks.

Keith Chisarik
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Let us know how it goes! BigGrin
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search