Dot-Net
沒有“WPF 功能區應用程序”的項目模板
我無法在 Visual Studio 中顯示 WPF 功能區項目。這是一個指向在 Visual Studio 2010 中遇到問題的人的執行緒的連結。
我已經嘗試了那裡建議的一切,但無濟於事。
我安裝了 Visual Studio 2012 Express for Desktop,但沒有顯示任何內容。我已經嘗試解除安裝並重新安裝,但沒有運氣。
一個簡單的解決方法是簡單地將和
<Window>替換為第一個孩子。請記住,功能區控制項已集成到 .NET 4.5 中。<RibbonWindow>``<Ribbon>
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 Framework 導入引用。
System.Windows.Controls.Ribbon編輯: 使用解決方案更新
VB.Net.1)添加參考
- 右鍵點擊您的項目並選擇
Add Reference.System.Windows.Controls.Ribbon在程序集和框架下查找。- 點擊
OK保存。
- 編輯你的
MainWindow.xaml
- 備份任何現有程式碼。
- 用我的範例中的程式碼替換預設模板。
- 在
<Ribbon></Ribbon>標籤中添加新內容。
- 編輯你的
Mainwindow.xaml.vb
- 右鍵點擊
MainWindow.xaml並點擊View Code。- 更改
Class Window為Class RibbonWindow。4)執行程序!