gpt4 book ai didi

wpf - 使用 Visual Studio 2017 在 WPF 应用程序中创建功能区

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

我在 Visual Studio 2017 中为 Windows 经典桌面创建了一个新的 WPF 应用程序。

我试图找到如何添加功能区,但我发现的内容与 Visual Studio 的旧版本有关,并且似乎在这里不起作用,或者我不明白如何去做。

如何使用 Visual Studio 2017 在 XAML/WPF 中添加功能区控件?

编辑:

我已经用这个 XAML 代码获得了一些东西:

<Window x:Class="WMathTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ribbon="clr-namespace:System.Windows.Controls.Ribbon.Primitives;assembly=System.Windows.Controls.Ribbon"
xmlns:local="clr-namespace:WMathTest"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<DockPanel>
<Ribbon>
<ribbon:RibbonTabsPanel></ribbon:RibbonTabsPanel>

</Ribbon>

</DockPanel>
</Window>

enter image description here

这是一个东西,但它是另一个窗口中的一个功能区窗口;功能区栏不像带有功能区的普通应用程序那样包含窗口名称和按钮。

最佳答案

您需要添加以下引用:System.Windows.Controls.Ribbon

然后使用 RibbonWindow 而不是 Window:

<RibbonWindow ...

还要记住更改部分的基类:
using System.Windows.Controls.Ribbon;

public partial class MainWindow : RibbonWindow
{
public MainWindow()
{
InitializeComponent();
}
}

关于wpf - 使用 Visual Studio 2017 在 WPF 应用程序中创建功能区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42725338/

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