This is what it looks like by default:
This is what I'm going for:
Notice the watch value:
And here is the code I'm using. Note: it looks ok if I uncomment the explicit width values of 60... but I'd rather not assume that the font metrics will always be the same as they are on my dev machine 
private static void ConfigureViewTag()
{
RibbonTab tabView = AddTab(ID.ID_TAB_VIEW, "View");
RibbonGroup groupPanes = AddGroup(tabView.Id, ID.ID_GROUP_PANES, "Panes", false, null);
viewObjectExplorerPane = AddControl(groupPanes.Id, "VIEW_OBJECT_EXPLORER_PANE", XTPControlType.xtpControlButton, "Object Explorer", "Show/Hide the Object Explorer Pane", "ToggleObjectExplorerPaneAction");
CommandBars.Icons.LoadIcon(Path.Combine(ResourceManager.ResourcePath, "object_explorer.ico"), viewObjectExplorerPane.Id, XtremeCommandBars.XTPImageState.xtpImageNormal);
viewPropertiesPane = AddControl(groupPanes.Id, "VIEW_PROPERTIES_PANE", XTPControlType.xtpControlButton, "Properties", "Show/Hide the Properties Pane", "TogglePropertiesPaneAction");
CommandBars.Icons.LoadIcon(Path.Combine(ResourceManager.ResourcePath, "properties.ico"), viewPropertiesPane.Id, XtremeCommandBars.XTPImageState.xtpImageNormal);
viewCalendarPane = AddControl(groupPanes.Id, "VIEW_CALENDAR_PANE", XTPControlType.xtpControlButton, "Calendar", "Show/Hide the Calendar Pane", "ToggleCalendarPaneAction");
CommandBars.Icons.LoadIcon(Path.Combine(ResourceManager.ResourcePath, "calendar.ico"), viewCalendarPane.Id, XtremeCommandBars.XTPImageState.xtpImageNormal);
SetEqualButtonWidth(groupPanes);
//viewObjectExplorerPane.Width = 60;
//viewPropertiesPane.Width = 60;
//viewCalendarPane.Width = 60;
}
public static void SetEqualButtonWidth(RibbonGroup group)
{
int maxWidth = 0;
foreach (CommandBarControl control in group)
{
if (control.Width > maxWidth)
maxWidth = control.Width;
}
foreach (CommandBarControl control in group)
{
control.Width = maxWidth;
}
}
public static CommandBarControl AddControl(int groupId, string resourceName, XTPControlType controlType, string controlCaption, string controlDescription, string actionMethod)
{
RibbonGroup group = RibbonBar.FindGroup(groupId);
int resourceId = ResourceManager.AddResource(resourceName);
CommandBarControl control = group.Add(controlType, resourceId, controlCaption, false, false);
control.Action.Tag = actionMethod;
CommandBars.Actions.Add(resourceId, controlCaption, controlCaption, controlDescription, group.Caption);
return control;
}
|