Hello,
I need to design a Ribbon like shown in picture 1 (Top picture)
What i've done so far is shown in picture 2 (Bottom pic).
I have two problems here:
1) I need to move some tools more to the left (Yellow arrow)
2) I need to make the RibbonGroup, espacially the caption area, to look more like where the red arrow is.
The caption must be placed more inside of the group and with a border all around the group. Please see the picture because I can't explain it better.
Thanks for your help,
Regards
Michael
Hi Michael,
Thank you for contacting Infragistics Developer Support.
I am glad that you have resolved your issue. Let me know if you have any additional questions.
Hi Milko,
thanks for your help. Especially the part for drawing the borders is very helpful. Thanks!
I changed the tool reposition code a bit so that it is more generic and works with different sizes ans setups.
Maybe that is of some help for others
public class RibbonGroupCreationFilter : IUIElementCreationFilter { public void AfterCreateChildElements( UIElement parent ) { // Only RibbonGroups are processed if(parent is RibbonGroupUIElement) { // Do we have children? if(parent.HasChildElements) { // Find caption element UIElement groupCaption = parent.ChildElements.FirstOrDefault(x => x is RibbonGroupCaptionAreaUIElement); // If no caption is visible we do not need to reposition anything if(groupCaption != null) { // Reposition group caption, move caption 4px up groupCaption.Offset(0, -4, true); // Recalc max height for tools int maxToolAreaHeight = groupCaption.Rect.Y - parent.Rect.Y - 2; // Get child elements without caption and separator, group these remaining // tools by x-Position var uiElementGroups = parent.ChildElements.Where (( x ) => !(x is RibbonGroupCaptionAreaUIElement) && !(x is RibbonGroupSeparatorUIElement)).GroupBy(x => x.Rect.X); ; foreach(var xGrp in uiElementGroups) { // Reposition every tool, max 3 in one column // If we have only one tool and its height is too big we need to shrink it int counterYPixel = -1; foreach(var tool in xGrp) { // Do we have a large-sized tool? if(tool.Rect.Height > maxToolAreaHeight) { tool.Rect = new Rectangle(tool.Rect.X, tool.Rect.Y, tool.Rect.Width, maxToolAreaHeight); } else { tool.Offset(0, counterYPixel, true); counterYPixel--; } } } } } } } public bool BeforeCreateChildElements( UIElement parent ) { return false; }
}
Hello Michael,
I think you are on the right way. With the help of Creational and Draw filters you can position both Ribbon tools and caption area and draw the RibbonGroup border.
1. Regarding caption area your Creation filter is exactly what you need.
2. Regarding tools I have changed your solution. Now all tools are translated to the left.
3. Regarding borders I have implemented in the solution one Draw filter.
Please find attached updated version of your Creation filter with added one Draw filter.
Please let me know if this is what you are looking for or if I am missing something.
In the meantime I found a way to at least move the group caption more up. But still have the problem with the borders, Any Ideas?
Thanks
public class RibbonGroupCreationFilter : IUIElementCreationFilter { public void AfterCreateChildElements( UIElement parent ) { if(parent is RibbonGroupUIElement) { foreach(UIElement element in parent.ChildElements) { if(element is RibbonGroupCaptionAreaUIElement) { element.Offset(0, -4, true); } else if(element is RibbonGroupSeparatorUIElement) { // Do nothing here!! } else { element.Offset(0, -2, true); } } } } public bool BeforeCreateChildElements( UIElement parent ) { return false; }}