Hello,
I'm currently adding UltraExplorerBarGroups to an UltraExplorerBar by dragging items from an UltraTree. What I'd like to do is show a drop location indicator in the explorer bar when I'm adding a new item in between existing items. Basically, the same indicator when you drag groups around to rearrage their order. Thanks.
This can be done using either the IUIElementDrawFilter or IUIElementCreationFilter interfaces. The UltraTree samples that ship with the SDK include an UltraTree example of the IUIElementDrawFilter approach, which demonstrates the concept, but it refers to UltraTree rather than UltraExplorerBar.
To quickly explain how this could be done with a creation filter: There is already a UIElement class (ItemDropHighlightUIElement) that does the drawing, which you could use (to be honest it is a very simple element and using it will not save you a huge amount of time over creating your own). When you implement IUIElementCreationFilter, you would add one of these elements to the ItemAreaInnerUIElement's ChildElements collection. To know where it goes, you would have to track the item closest to the cursor position, which you can use the ItemFromPoint method to do.
Thanks for the response Brian. I haven't actually verified that this will work (clicked the wrong link), but I feel that I'm headed down the right path now. It'll take me some time to actually implement though it since I'm new to Infragistics controls.
Ah, I think I'm starting to see where my confusion came from. What I really want to do is show a drop location in between existing *groups*, not items. Basically, in the empty/dead space in between groups controlled by the GroupSpacing property. lf that's the case, was I doing the correct thing when I added the drop indicator to the group's child elements? That is:
group.UIElement.ChildElements.Add(dropHighlightElement);
Some UIElements are the physical manifestations of the objects exposed by the control; for example, the GroupUIElement is the physical manifestation of an UltraExplorerBarGroup. Many elements, GroupUIElement included, have constituent elements, such as the ItemAreaInnerUIElement and the UltraExplorerBarGroupHeaderUIElement. ItemAreaInnerUIElement just happens to be the element that contains the items, and in your original post you expressed the desire to show a drop location indicator in between existing items.
What's the reasoning behind adding it to ItemAreaInnerUIElement and not GroupUIElement? Does it have something to do with draw regions or draw order?
Sorry for all the questions, but I'm new to using Infragistics controls and I haven't been able to locate a document that explains how all these elements relate/interact with one another. Thanks for all of your help so far.
Your suspicion was correct, you don't want to add it to the GroupUIElement, you want to add it to the ItemAreaInnerUIElement. The reason the ChildElements collection is empty is because there are no items in the group.
I think I have a lead on what's going on now. DrawForeground will not get called if it can't draw in the specified rectangle. In this case, ItemAreaInnerUIElement's rectangle has a height of 0, so the drop highlight will never get drawn. My code works because DrawForeground will draw the line inside the UltraExplorerBarGroup rectangle, which would work ok.
So, is it fine for me to leave the code as-is, or should I be looking at changing ItemAreaInnerUIElement size somehow? Or to put it another way, do I have to draw the drop highlight inside ItemAreaInnerUIElement? Thanks.