没有“WPF功能区应用程序”的项目模板



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

我已经尝试了那里建议的所有方法,但无济于事。

我已经安装了Visual Studio 2012 Express for Desktop,但没有显示任何内容。

一个简单的工作是简单地将<Window>替换为<RibbonWindow><Ribbon>作为第一个孩子。请记住,Ribbon控件已经集成到。net 4.5中。

首先编辑您的MainWindow.xaml替换WindowRibbonWindow,并添加<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类而不是Window

public partial class MainWindow : RibbonWindow

最后记得从。net框架中导入引用。

System.Windows.Controls.Ribbon

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

1)添加参考
    右键单击你的项目,选择Add Reference
  • 在Assemblies and Framework下找到System.Windows.Controls.Ribbon
  • 点击OK保存
编辑你的MainWindow.xaml
    备份所有现有代码。
  • 用示例中的代码替换默认模板。
  • <Ribbon></Ribbon>标签内添加您的新内容。
编辑你的Mainwindow.xaml.vb
  • 右键单击MainWindow.xaml,点击View Code
  • Class Window改为Class RibbonWindow

4)运行程序!

最新更新