Hiding / Showing UIElements

Topics: CAB & Smart Client Software Factory
Oct 18, 2005 at 9:35 AM
originally posted by: aaguiarz

In the previous CTP, when a WorkItem was deactivated, all its UIElements were hidden. This is no longer the case in the current CTP.

Should we handle it in our code, or you will provide a way to do it in the final release?

Oct 18, 2005 at 12:23 PM
originally posted by: jolu1977

Yes you should handle this in your own code. It is too hard to generalize what users want to do when a workitem is deactivated or activated.

We are updating the BankTeller QuickStart to better illustrate this.
Oct 18, 2005 at 5:34 PM
originally posted by: aaguiarz

OK, no problem, but how should I get a reference to the UI element I want to hide?

I don't have local members with the toolstrip items... Additionally, UIElements are not added to the IUIElementService with an ID, just with the site, so I'm not sure if there's a way to ask for the ToolStripItem ...

Thanks a lot.
Oct 19, 2005 at 6:13 AM
originally posted by: jolu1977

The UIElementService is responsible for defining places (ExtensionSites) where you can add/remove UIElements and the underlying managers are responsible for the actual adding and removing. There is not a way of locating elements like there was in the past, there will be however a way to iterate over items in an ExtensionSite.

The way I would go about hiding a UIElement you do not have a reference to is to use commands.

The reason we did away with the locating of UIElements is other workitems should not be mucking with UIElements of another. Thus the one doing the mucking is the one that put it there (or a child workitem), so there could be a reference to it but if not use commands.
Oct 19, 2005 at 8:31 AM
originally posted by: aaguiarz

I don't have references to any UIElement.... even the WorkItem who creates them, does not have references to them.

Also, how do I hide an element with a command? AFAIK I can disable them but not hide them.

The only solution I see right now is to keep a reference to the real UIElements controls in the WorkItem. When I process the 'command map' in addition of creating new UIElements and registering them, I'll add them to a local Control collection ...
Oct 19, 2005 at 9:06 AM
originally posted by: jolu1977

After the CTP2 drop we added a CommandStatus which has Enable, Disable and Unavailable. In the ControlCommandAdapter and the ToolStripItemCommandAdapter in the OnCommandChanged now set the visible property based on Unavailable Status.

Just to reiterate, this was added after the CTP2 drop and will be in the final code drop.

You can add to existing or create your own command adapters that give you the behavior you need now and then switch to the one that will be provided in the final drop.
Oct 19, 2005 at 9:15 AM
originally posted by: aaguiarz

OK, great, thanks!
Oct 20, 2005 at 4:46 AM
originally posted by: Phyrefly

Thanks bro, I implemented that change too and it's awsome!!!
Oct 21, 2005 at 12:53 PM
originally posted by: jwalklin

You also need to take care of the case where a ToolStripButton is in the checked/unchecked state.