首先,您将 RibbonTabs 作为资源放置在您想要的任何 ResourceDictionary 中:
<Application.Resources>
<r:RibbonTab Label="Tab_A" x:Key="RibControl_A">
<r:RibbonGroup>
<r:RibbonButton>
<r:RibbonButton.Command>
<r:RibbonCommand LabelTitle="CommandA"/>
</r:RibbonButton.Command>
</r:RibbonButton>
</r:RibbonGroup>
</r:RibbonTab>
<r:RibbonTab Label="Tab_B" x:Key="RibControl_B">
<r:RibbonGroup>
<r:RibbonButton>
<r:RibbonButton.Command>
<r:RibbonCommand LabelTitle="CommandB"/>
</r:RibbonButton.Command>
</r:RibbonButton>
</r:RibbonGroup>
</r:RibbonTab>
</Application.Resources>
然后你可以将它们引用为 StaticResources
<r:Ribbon>
<r:Ribbon.Tabs>
<StaticResource ResourceKey="RibControl_A" />
<StaticResource ResourceKey="RibControl_B" />
</r:Ribbon.Tabs>
</r:Ribbon>
这对我来说编译并成功运行。