Dot-Net

沒有“WPF 功能區應用程序”的項目模板

  • March 22, 2013

我無法在 Visual Studio 中顯示 WPF 功能區項目。是一個指向在 Visual Studio 2010 中遇到問題的人的執行緒的連結。

我已經嘗試了那裡建議的一切,但無濟於事。

我安裝了 Visual Studio 2012 Express for Desktop,但沒有顯示任何內容。我已經嘗試解除安裝並重新安裝,但沒有運氣。

一個簡單的解決方法是簡單地將和<Window>替換為第一個孩子。請記住,功能區控制項已集成到 .NET 4.5 中。<RibbonWindow>``<Ribbon>

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 Framework 導入引用。

System.Windows.Controls.Ribbon

編輯: 使用解決方案更新VB.Net.

1)添加參考

  • 右鍵點擊您的項目並選擇Add Reference.
  • System.Windows.Controls.Ribbon在程序集和框架下查找。
  • 點擊OK保存。
  1. 編輯你的MainWindow.xaml
  • 備份任何現有程式碼。
  • 用我的範例中的程式碼替換預設模板。
  • <Ribbon></Ribbon>標籤中添加新內容。
  1. 編輯你的Mainwindow.xaml.vb
  • 右鍵點擊MainWindow.xaml並點擊View Code
  • 更改Class WindowClass RibbonWindow

4)執行程序!

引用自:https://stackoverflow.com/questions/15559921