在 Fluent Ribbon Control Suite 中,有没有办法让上下文选项卡组首先显示而不是最后显示?我使用的是旧版本,前三个选项卡项有一个上下文选项卡组,另外两个没有组。下载并构建了最新的源码;组中的选项卡现在位于右端。我希望它们以与我在 xaml 中指定的顺序相同的顺序显示。我没有看到任何明显的属性可以让我指定顺序。
问问题
641 次
1 回答
0
由于没有人对此有答案,而我刚刚获得了 Tumbleweed 徽章 :),我决定发布我的解决方案,即修改 Fluent Ribbon Control Suite 代码。我ArrangeOverride
在RibbonTabsContainer
课堂上修改。这导致分组选项卡在不属于组的选项卡之前呈现:
/// <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;
}
于 2013-05-23T21:21:08.913 回答