FluentWPF 项目教程
FluentWPFFluent Design System for WPF.项目地址:https://gitcode.com/gh_mirrors/fl/FluentWPF
1、项目的目录结构及介绍
FluentWPF 项目的目录结构如下:
FluentWPF/
├── FluentWPF/
│ ├── Assets/
│ ├── Converters/
│ ├── Themes/
│ ├── FluentWPF.csproj
│ ├── AcrylicBrush.cs
│ ├── AcrylicWindow.cs
│ ├── RevealBackgroundBrush.cs
│ ├── RevealBorderBrush.cs
│ ├── ResourceDictionaryEx.cs
│ ├── SystemTheme.cs
│ ├── ThemeManager.cs
│ └── ...
├── Samples/
│ ├── AcrylicWindowSample/
│ ├── RevealSample/
│ ├── ParallaxSample/
│ └── ...
├── .gitignore
├── FluentWPF.sln
├── README.md
└── ...
目录结构介绍
-
FluentWPF/: 包含 FluentWPF 库的核心代码。
- Assets/: 包含项目所需的资源文件,如图片等。
- Converters/: 包含用于数据转换的类。
- Themes/: 包含项目的主题资源文件。
- FluentWPF.csproj: 项目的 C# 项目文件。
- AcrylicBrush.cs: 实现亚克力效果的画刷类。
- AcrylicWindow.cs: 实现亚克力效果的窗口类。
- RevealBackgroundBrush.cs: 实现 Reveal 背景效果的画刷类。
- RevealBorderBrush.cs: 实现 Reveal 边框效果的画刷类。
- ResourceDictionaryEx.cs: 扩展资源字典类。
- SystemTheme.cs: 系统主题类。
- ThemeManager.cs: 主题管理类。
- ...: 其他辅助类和文件。
-
Samples/: 包含示例项目,展示如何使用 FluentWPF 库。
- AcrylicWindowSample/: 亚克力窗口示例。
- RevealSample/: Reveal 效果示例。
- ParallaxSample/: 视差滚动效果示例。
- ...: 其他示例项目。
-
.gitignore: Git 忽略文件配置。
-
FluentWPF.sln: 解决方案文件。
-
README.md: 项目说明文档。
-
...: 其他辅助文件。
2、项目的启动文件介绍
FluentWPF 项目的启动文件通常是 App.xaml
和 App.xaml.cs
。
App.xaml
<Application x:Class="FluentWPF.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>
<ResourceDictionary Source="Themes/Generic.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
App.xaml.cs
using System.Windows;
namespace FluentWPF
{
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
ThemeManager.Current.Theme = Theme.Dark;
}
}
}
启动文件介绍
-
App.xaml: 定义了应用程序的启动界面和资源字典。
StartupUri="MainWindow.xaml"
: 指定应用程序启动时加载的主窗口。ResourceDictionary.MergedDictionaries
: 合并主题资源字典。
-
App.xaml.cs: 应用程序的代码隐藏文件。
OnStartup(StartupEventArgs e)
: 重写启动事件,设置应用程序的主题。
3、项目的配置文件介绍
FluentWPF 项目的配置文件主要是 FluentWPF.csproj
和 FluentWPF.sln
。
FluentWP
FluentWPFFluent Design System for WPF.项目地址:https://gitcode.com/gh_mirrors/fl/FluentWPF