gpt4 book ai didi

wpf - 如何以编程方式切换功能区选项卡?

转载 作者:行者123 更新时间:2023-12-04 17:28:17 25 4
gpt4 key购买 nike

我的 View 中有一个名为“ribbon”的功能区,它有 2 个选项卡,如下面的示例代码。我希望 Button1 在点击时会打开 Tab2,反之亦然。我该怎么做?

<ribbon:Ribbon x:Name="ribbon" HelpPaneContent="{x:Static data:WordModel.Help}">
<ribbon:RibbonTab Header="Tab1" ... >
<ribbon:RibbonGroup x:Name="Button1" >
<ribbon:RibbonButton Clicked="SwitchToTab2" />
</ribbon:RibbonGroup>
</ribbon:RibbonTab>

<ribbon:RibbonTab Header="Tab2" ... >
<ribbon:RibbonGroup x:Name="Button2" >
<ribbon:RibbonButton Clicked="SwitchToTab1" />
</ribbon:RibbonGroup>
</ribbon:RibbonTab>
...
</ribbon:Ribbon>

最佳答案

您只需要触发选项卡的 IsSelected 属性

private void SwitchToTab1(object sender, MouseButtonEventArgs e)
{
ribbontab1.IsSelected = true;
}
private void SwitchToTab2(object sender, MouseButtonEventArgs e)
{
ribbontab2.IsSelected = true;
}

关于wpf - 如何以编程方式切换功能区选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3528981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com