本文使用工具 Visual Studio 2012 + .NET Framework 4.5
WPF現在可以設計類似 Office 2010 Ribbon效果的工具列了!!
建一個WPF APP
Add Reference:
修改MainWindow.xaml.cs,讓MainWindow 繼承自RibbonWindow
{
public MainWindow()
{
InitializeComponent();
}
}
修改MainWindow.xaml,將Window改RibbonWindow
加上<Ribbon></Ribbon>:
加圖檔到專案:
修改Ribbon:
<RibbonWindow x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Ribbon>
<RibbonTab Header="檔案">
<RibbonGroup >
<RibbonButton Label="存檔" LargeImageSource="button.png" ></RibbonButton>
<RibbonButton Label="開檔" LargeImageSource="arrow left.png"></RibbonButton>
</RibbonGroup>
</RibbonTab>
<RibbonTab Header="編輯">
<RibbonGroup>
<RibbonButton Label="複製" ></RibbonButton>
<RibbonButton Label="貼上"></RibbonButton>
</RibbonGroup>
</RibbonTab>
</Ribbon>
</Grid>
</RibbonWindow>
按F5執行:
沒有留言:
張貼留言