我无法在Visual Studio中显示WPF功能区项目。这里是一个链接到一个线程,有人在Visual Studio 2010中遇到了一个问题。
我已经尝试了那里建议的所有方法,但无济于事。
我已经安装了Visual Studio 2012 Express for Desktop,但没有显示任何内容。
一个简单的工作是简单地将<Window>
替换为<RibbonWindow>
和<Ribbon>
作为第一个孩子。请记住,Ribbon控件已经集成到。net 4.5中。
首先编辑您的MainWindow.xaml
替换Window
与RibbonWindow
,并添加<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
的解决方案。
- 右键单击你的项目,选择
- 在Assemblies and Framework下找到
System.Windows.Controls.Ribbon
- 点击
OK
保存
Add Reference
。MainWindow.xaml
- 备份所有现有代码。
- 用示例中的代码替换默认模板。
- 在
<Ribbon></Ribbon>
标签内添加您的新内容。
Mainwindow.xaml.vb
- 右键单击
MainWindow.xaml
,点击View Code
。 - 将
Class Window
改为Class RibbonWindow
。
4)运行程序!