至少有一种相当可接受的方法来解决这个问题,这也很简单:通过绑定和使用TabControl
每个视图的容器来关联到每个功能区选项卡。
- 将丝带和
TabControl
.
SelectedIndex
将选项卡控件的属性绑定到功能区的SelectedTabIndex
.
- 隐藏选项卡控件中所有选项卡项的标题。
代码:
<fluent:RibbonWindow
x:Class="FluentExample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:fluent="clr-namespace:Fluent;assembly=Fluent"
>
<DockPanel LastChildFill="True">
<fluent:Ribbon x:Name="_ribbon" DockPanel.Dock="Top">
<!-- Ribbon tabs -->
<fluent:RibbonTabItem Header="Tab #1" />
<fluent:RibbonTabItem Header="Tab #2" />
</fluent:Ribbon>
<!-- Views container -->
<TabControl
DockPanel.Dock="Bottom"
SelectedIndex="{Binding ElementName=_ribbon, Path=SelectedTabIndex}"
>
<!-- Hide tab items headers -->
<TabControl.ItemContainerStyle>
<Style TargetType="{x:Type TabItem}">
<Setter Property="Visibility" Value="Collapsed"/>
</Style>
</TabControl.ItemContainerStyle>
<!-- Individual content for each tab go here -->
<TabItem><TextBlock Text="First Content View (#1)" /></TabItem>
<TabItem><TextBlock Text="Second Content View (#2)" /></TabItem>
</TabControl>
</DockPanel>
</fluent:RibbonWindow>