第一步:引入Fluent Ribbon的庫
第一種方法:直接到github上下載,
下載地址:https://github.com/fluentribbon/Fluent.Ribbon
第二種方法:在VS項目引用處,點擊右鍵,彈出Nuget管理程序包,輸入Fluent.Ribbon查詢,安裝對應的包文件
第二步:設置默認皮膚
打開App.xaml文件,寫入如下配置,當前最新版本只定義了這個默認皮膚
<Application.Resources>
<ResourceDictionary Source="pack://application:,,,/Fluent;Component/Themes/Generic.xaml" />
</Application.Resources>
第三步 設置窗體為RibbonWindow
如下圖,窗體為RibbonWindow類型,並且引入Fluent的命名空間:xmlns:Fluent="urn:fluent-ribbon"
第四步,創建Ribbon控件
- 定義RowDefinition
- 創建Fluent:Ribbon
代碼如下所示:
<Fluent:RibbonWindow x:Class="DesignLGK.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markupcompatibility/2006" xmlns:local="clr-namespace:DesignLGK" xmlns:Fluent="urn:fluent-ribbon" mc:Ignorable="d" Title="" Height="600" Width="800" WindowState="Maximized"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto"></RowDefinition> <RowDefinition></RowDefinition> <RowDefinition></RowDefinition> </Grid.RowDefinitions> <Fluent:Ribbon Grid.Row="0"> <Fluent:RibbonTabItem Header="項目" IsSelected="True"></Fluent:RibbonTabItem> </Fluent:Ribbon> </Grid> </Fluent:RibbonWindow> |
完成以后,其界面如下: