本文最后更新于 2019年11月28日 已经是 1398天前了 ,文章可能具有时效性,若有错误或已失效,请在下方留言。
环境
这里博主用的是
VS
UI界面
- 采用
MahApps.Metro
- smirk:
1. 安装Nuget的 MahApps.Metro
2. 添加引用
xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
将<Window …标签更改为 <Controls:MetroWindow
- 更改.CS代码文件:
public partial class MainWindow : MetroWindow
- 替换app.xml
<Application x:Class="WpfApplication.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" />
<ResourceDictionary Source="/Resources/Icons.xaml" />
<!-- Accent and AppTheme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
- 最大化最小化按钮
<Controls:MetroWindow x:Class="WpfApplication.MainWindow"
...
ShowIconOnTitleBar="True"
ShowTitleBar="True">
</Controls:MetroWindow>
- 记住窗口位置
aveWindowPosition=”True|False”
- 窗口边框
- 有边框
BorderBrush="{DynamicResource AccentColorBrush}"
BorderThickness="1"
- 发光边框
GlowBrush="{DynamicResource AccentColorBrush}"
- 阴影边框
GlowBrush="{DynamicResource AccentColorBrush}"
Test 测试