一、安装工具包
1、打开程序包管理器控制台
视图 > 其他窗口 > 程序包管理器控制台
2、安装程序包
打开管理NuGet程序包,搜索MaterialDesignThemes,进行安装
打开 视图 .> 其他窗口 > 程序包管理控制台
在程序包管理控制台中输入:
PM> Install-Package MaterialDesignThemes
PM> Install-Package ShowMeTheXAML.MSBuild
二、修改配置App.xaml
App.xaml文件
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApp3" StartupUri="MainWindow.xaml">
三、在WPF窗口Xaml中引入命名控件
在MainWindow.xaml中的Window标签中添加
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" [...] > 四、使用MaterialDesign控件 IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" Opened="PopupBox_OnOpened" PlacementMode="BottomAndAlignCentres" Style="{StaticResource MaterialDesignMultiFloatingActionPopupBox}" ToolTip="PopupBox, Style MaterialDesignMultiFloatingActionPopupBox" ToolTipService.Placement="Right"> 此时代码报错,因为缺少一些引用。上述代码中使用了PopupBox控件,继续在App.xaml中添加 引用的程序集不全,有一些控件需要单独在App.xaml中引用一下程序集。 五、效果 精彩链接
发表评论