将C# WPF程序迁移至Linux的最优方案咨询
Hey Jeff, let's break down the most straightforward ways to get your DnD character generator running on Linux without pulling your hair out—since you already know C#, we'll lean into that as much as possible to minimize the learning curve.
Top Pick: Avalonia UI
This is hands down the easiest path for you. Avalonia is a cross-platform UI framework built to feel nearly identical to WPF, but it runs natively on Linux (plus Windows, macOS, and even the web). Here's why it's perfect for your use case:
- Your existing C# business logic (the DnD character generation code) should port over almost directly—no rewrites needed there.
- Most of your WPF XAML for the tabbed GUI will only need minor tweaks (if any). Avalonia supports
TabControland drag-and-drop functionality just like WPF, so your core UI structure stays intact. - You can keep using familiar tools: Rider, Visual Studio Code with Avalonia extensions, or even Visual Studio if you're still working on Windows part-time.
- The project is actively maintained, so you won't run into the "abandoned tool" issue you faced with Moonlight.
Just start a new Avalonia project, copy over your view models and character logic, then adjust your XAML to match Avalonia's small API differences (their official docs have a super clear WPF migration guide to walk you through it).
Runner Up: .NET MAUI
If you prefer sticking strictly to Microsoft's ecosystem, .NET MAUI supports Linux (as of .NET 7). While it's primarily focused on mobile apps, it works for desktop too. Here's the catch:
- Your C# logic is still fully reusable, but the XAML syntax and UI components have more differences from WPF compared to Avalonia. You'll need to rewrite more of your tabbed UI layer.
- MAUI's Linux support is stable but not as mature as Avalonia's, so you might hit a few edge cases with drag-and-drop or custom tab styling.
Still, since you're already comfortable with C# and .NET, this is a viable option without switching to a totally new language.
Honorable Mention: GTK#
If you don't mind rebuilding your UI from scratch but want to stay in the C# world, GTK# (part of the Mono project) is a Linux-native UI framework worth considering:
- All your DnD character generation logic can remain 100% C#—you just need to build a new tabbed interface using GTK's widgets.
- GTK is well-established on Linux, so there's plenty of documentation and community support for desktop apps.
The downside is you'll have to learn GTK's UI paradigm, which is quite different from WPF's XAML-based approach, but you won't have to learn a new programming language.
Final Recommendation
Go with Avalonia UI first—it's the closest to WPF, requires the least amount of rewrite work, and keeps you in the C# ecosystem you already know. It's the fastest way to get your DnD generator up and running on Linux without major headaches.
内容的提问来源于stack exchange,提问作者Jeff Godzilla




