在Fluent功能区控件套件中,有没有办法让上下文选项卡组首先显示而不是最后显示?我使用的是旧版本,并且前三个标签项有一个上下文选项卡组,另外两个没有组。下载并构建了最新的源代码;组中的选项卡现在位于右端。我希望它们以与我在xaml中指定的顺序相同的顺序显示。我没有看到任何允许我指定订单的明显属性。
答案 0 :(得分:0)
由于没有人对此有答案,而我刚拿到了Tumbleweed徽章:),我决定发布我的解决方案,即修改Fluent Ribbon Control Suite代码。我修改了ArrangeOverride
类中的RibbonTabsContainer
。这导致Grouped选项卡在不在组中的选项卡之前呈现:
/// <summary>
/// Positions child elements and determines
/// a size for the control
/// </summary>
/// <param name="finalSize">The final area within the parent
/// that this element should use to arrange
/// itself and its children</param>
/// <returns>The actual size used</returns>
protected override Size ArrangeOverride(Size finalSize)
{
var finalRect = new Rect(finalSize)
{
X = -this.HorizontalOffset
};
var orderedChildren = this.InternalChildren.OfType<RibbonTabItem>()
.OrderByDescending(x => x.Group != null); // <==== originally .OrderBy
foreach (var item in orderedChildren)
{
finalRect.Width = item.DesiredSize.Width;
finalRect.Height = Math.Max(finalSize.Height, item.DesiredSize.Height);
item.Arrange(finalRect);
finalRect.X += item.DesiredSize.Width;
}
var ribbonTabItemsWithGroups = this.InternalChildren.OfType<RibbonTabItem>()
.Where(item => item.Group != null);
var ribbonTitleBar = ribbonTabItemsWithGroups.Select(ribbonTabItemsWithGroup => ribbonTabItemsWithGroup.Group.Parent)
.OfType<RibbonTitleBar>()
.FirstOrDefault();
if (ribbonTitleBar != null)
{
ribbonTitleBar.InvalidateMeasure();
}
return finalSize;
}