赞
踩
视图 > 其他窗口 > 程序包管理器控制台
打开管理NuGet程序包,搜索MaterialDesignThemes,进行安装
打开 视图 .> 其他窗口 > 程序包管理控制台
在程序包管理控制台中输入:
- PM> Install-Package MaterialDesignThemes
- PM> Install-Package ShowMeTheXAML.MSBuild
App.xaml文件
- <Application x:Class="WpfApp3.App"
- 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">
-
- <Application.Resources>
- <ResourceDictionary>
- <ResourceDictionary.MergedDictionaries>
- <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
- <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
- <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
- <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
- </ResourceDictionary.MergedDictionaries>
- </ResourceDictionary>
- </Application.Resources>
- </Application>
在MainWindow.xaml中的Window标签中添加
- <Window [...]
- xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
- [...] >
- <Grid>
- <materialDesign:PopupBox Closed="PopupBox_OnClosed"
- IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
- Opened="PopupBox_OnOpened"
- PlacementMode="BottomAndAlignCentres"
- Style="{StaticResource MaterialDesignMultiFloatingActionPopupBox}"
- ToolTip="PopupBox, Style MaterialDesignMultiFloatingActionPopupBox"
- ToolTipService.Placement="Right">
- <StackPanel>
- <Button
- Content="1"
- Opacity="0.5"
- ToolTip="One with custom opacity" />
- <Button
- Content="2"
- ToolTip="Two" />
- <Button
- Content="3"
- ToolTip="Three" />
- </StackPanel>
- </materialDesign:PopupBox>
- </Grid>
此时代码报错,因为缺少一些引用。上述代码中使用了PopupBox控件,继续在App.xaml中添加
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PopupBox.xaml" />
引用的程序集不全,有一些控件需要单独在App.xaml中引用一下程序集。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。