Apply Avalonia 12 migration changes: replace SystemDecorations with WindowDecorations and remove ExtendClientAreaChromeHints/ExtendClientAreaTitleBarHeightHint usages; update BindingPlugins removal logic (no-op); switch clipboard usage to ClipboardExtensions.SetTextAsync; update Bitmap.CopyPixels calls to the new signature. Replace TextBox.Watermark with PlaceholderText, convert NumberBox styles to FANumberBox and adjust templates, change Checked/Unchecked handlers to IsCheckedChanged, and adapt FluentIcons usages (SymbolIconSource -> FASymbol/FAFont/FluentIcon equivalents). Fix MainWindow partial classes to inherit Window and correct missing variables/fields/usings. Add migration docs/specs/tasks under .trae and include a small TestFluentIcons project for icon testing.
3.3 KiB
Avalonia 12 迁移计划
当前状态
项目已完成以下迁移准备:
-
Directory.Packages.props中 Avalonia 包已升级到12.0.1 -
FluentAvaloniaUI已升级到3.0.0-preview1 -
Avalonia.Diagnostics已替换为AvaloniaUI.DiagnosticsSupport -
Avalonia.Controls.WebView已升级到12.0.0 -
ClassIsland.Markdown.Avalonia已升级到12.0.0
构建错误清单(26 errors)
1. 窗口装饰 API 移除(8 errors)
文件:LanMountainDesktop/Views/SettingsWindow.axaml.cs(4 errors)
-
ExtendClientAreaChromeHints不存在(line 166, 179) -
SystemDecorations已过时,需改用WindowDecorations(line 168, 177)
文件:LanMountainDesktop/Views/ComponentEditorWindow.axaml.cs(4 errors)
-
ExtendClientAreaChromeHints不存在(line 63, 72) -
SystemDecorations已过时,需改用WindowDecorations(line 65, 70)
AXAML 文件:13 个文件使用 SystemDecorations 属性(编译警告)
2. 变量/字段未找到(8 errors)
文件:LanMountainDesktop/Views/MainWindow.ComponentSystem.cs
-
centerLeft不存在(line 759, 766, 778) -
positions不存在(line 1266)
文件:LanMountainDesktop/Views/MainWindow.DesktopPaging.cs
-
child不存在(line 312) -
_isThreeFingerOrRightDragSwipeActive不存在(line 517, 828, 847, 850)
3. API 变更(3 errors)
文件:LanMountainDesktop/App.axaml.cs
BindingPlugins不可访问(line 532, 537)
文件:LanMountainDesktop/Views/Components/DesktopComponentFailureView.cs
IClipboard.SetTextAsync不存在(line 187)
文件:LanMountainDesktop/Services/MonetColorService.cs
Bitmap.CopyPixels参数不匹配(line 91)
4. 第三方库变更(1 error)
文件:LanMountainDesktop/Views/SettingsWindow.axaml.cs
FluentIcons.Avalonia.SymbolIconSource不存在(line 215)
5. 过时属性警告(需同步修复)
TextBox.Watermark→PlaceholderText(7 处 .cs + 7 处 .axaml)
迁移步骤
Phase 1: 修复窗口装饰 API(高优先级)
- 重写
SettingsWindow.ApplyChromeMode()使用 Avalonia 12 新 API - 重写
ComponentEditorWindow.ApplyChromeMode()使用 Avalonia 12 新 API - 批量替换所有
.axaml中的SystemDecorations→WindowDecorations
Phase 2: 修复 MainWindow 编译错误(高优先级)
- 检查
MainWindow.ComponentSystem.cs中centerLeft和positions的作用域问题 - 检查
MainWindow.DesktopPaging.cs中child和_isThreeFingerOrRightDragSwipeActive的作用域问题 - 确认这些变量是否被意外删除或重命名
Phase 3: 修复 Avalonia 12 API 变更(中优先级)
App.axaml.cs: 替换BindingPlugins.DataValidators的访问方式DesktopComponentFailureView.cs: 使用新的剪贴板 APIMonetColorService.cs: 更新Bitmap.CopyPixels调用签名
Phase 4: 修复第三方库变更(中优先级)
SettingsWindow.axaml.cs: 替换FluentIcons.Avalonia.SymbolIconSource为 v3 等效 API
Phase 5: 清理过时属性(低优先级)
- 批量替换
Watermark→PlaceholderText(所有 .cs 和 .axaml)
验证步骤
-
每阶段修复后运行
dotnet build LanMountainDesktop.slnx -c Debug -
最终运行
dotnet test LanMountainDesktop.slnx -c Debug