没有了“WPF丝带应用”项目模板丝带、没有了、模板、项目

2023-09-03 12:43:27 作者:酒杯中的大海

我是无法得到一个WPF功能区项目在Visual Studio中显示。 Here是一个链接到一个线程有人在Visual Studio 2010中有一个问题。

I am unable to get a WPF Ribbon project to show in Visual Studio. Here is a link to a thread for someone that had an issue in Visual Studio 2010.

我已经试过各种建议有,但都无济于事。

I have tried everything suggested there but to no avail.

我的Visual Studio 2012例preSS已安装的桌面,但什么也没有显示出来。我试图卸载并重新安装,但没有运气。

I have Visual Studio 2012 Express for Desktop installed but nothing is showing up. I have tried uninstalling and re-installing but no luck.

推荐答案

一个简单的变通办法是简单地替换<窗​​口> < RibbonWindow> <丝带> 作为第一个孩子。请记住,在Ribbon控制已经集成到.NET 4.5。

A simple work around would be to simply replace <Window> with <RibbonWindow> and <Ribbon> as the first child. Keep in mind that the Ribbon control is already integrated into .NET 4.5.

首先修改 MainWindow.xaml 替换窗口 RibbonWindow 并添加&LT;丝带×:名称=丝带标题=丝带标题&GT;

First edit your MainWindow.xaml by replacing Window with RibbonWindow and add <Ribbon x:Name="Ribbon" Title="Ribbon Title">.

示例:

<RibbonWindow x:Class="WpfApplication3.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

        Title="MainWindow"
        x:Name="RibbonWindow"
        Width="640" Height="480">

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Ribbon x:Name="Ribbon" Title="Ribbon Title">
            ...........
        </Ribbon>
    </Grid>
</RibbonWindow>

您还需要编辑 MainWindow.xaml.cs 继承 RibbonWindow 类而不是窗口

You will also need to edit the MainWindow.xaml.cs to inherit the RibbonWindow class instead of Window.

public partial class MainWindow : RibbonWindow

最后记得要导入从.NET Framework中的参考。

Last remember to import the reference from the .NET Framework.

System.Windows.Controls.Ribbon

编辑: 更新与解决方案 VB.Net

1)添加引用

右键点击您的项目,并选择添加引用。 找到 System.Windows.Controls.Ribbon 组件和框架下。 点击确定保存。 Right click on your project and choose Add Reference. Find System.Windows.Controls.Ribbon under Assemblies and Framework. Click OK to save.

2)修改 MainWindow.xaml

备份任何现有的code。 替换为code。在我的例子中默认的模板。 在中添加新的内容&LT;丝带&GT;&LT; /丝带&GT; 标记 Back up any existing code. Replace the default template with the code in my Example. Add your new content within the <Ribbon></Ribbon> tag.

3)修改 Mainwindow.xaml.vb

右键点击 MainWindow.xaml ,点击查看code 。 修改类窗口类RibbonWindow 。 Right click on MainWindow.xaml and click View Code. Change Class Window to Class RibbonWindow.

4)运行程序!