是否有用于 C#/.NET 的跨平台 GUI 框架?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/779283/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is there a cross-platform GUI framework for C#/.NET?
提问by Jay R.
Let's say just for the joy of it, I decide that I don't want to write desktop applications in Java any more, instead want to switch to using C#. I want to be able to build an application that will run on some mainstream Linux distribution, and a recent release of MS Windows. It will have a GUI component.
让我们说只是为了它的乐趣,我决定不再想用 Java 编写桌面应用程序,而是想改用 C#。我希望能够构建一个可以在一些主流 Linux 发行版和最近版本的 MS Windows 上运行的应用程序。它将有一个 GUI 组件。
In Java I can build an application that uses Swing. Once I have it working, I can copy that jar file from Windows to Linux or vice versa, depending where I developed it. And it will generally run with java -jar myapp.jar
.
在 Java 中,我可以构建一个使用 Swing 的应用程序。一旦我开始工作,我可以将该 jar 文件从 Windows 复制到 Linux,反之亦然,这取决于我在哪里开发它。它通常会与java -jar myapp.jar
.
In C# is it possible to do this? Is there a functional equivalent to Swing or AWT in C#?
在 C# 中可以这样做吗?在 C# 中是否有与 Swing 或 AWT 等效的功能?
回答by John T
You can try WxWidgets. It has support for C#, among many other languages, and is cross-platform. The only downside being a recompile for each platform. Alternatively you can try Mono which is very good, but beware there are a couple snags with compatibility issues. There is no predefined "run anywhere" file for C# apps yet like Java has with jars though, you're best bet is to recompile for each platform if you want to ensure compatibility.
你可以试试WxWidgets。它支持 C# 以及许多其他语言,并且是跨平台的。唯一的缺点是每个平台都需要重新编译。或者,您可以尝试 Mono,它非常好,但要注意兼容性问题存在一些障碍。C# 应用程序没有预定义的“在任何地方运行”文件,但就像 Java 有 jars 一样,如果你想确保兼容性,你最好为每个平台重新编译。
回答by Sam Schutte
The closest thing I've ever seen is Mono - though it doesn't support all the CLR libraries yet I believe, but it is cross-platform.
我见过的最接近的东西是 Mono - 虽然我相信它不支持所有 CLR 库,但它是跨平台的。
回答by Rob
I believe a good portion of WinForms is implemented in Mono. You need to install Mono under Linux for that. You may have compatibility problems, though, since Mono is not a Microsoft effort and is not officially supported by them.
我相信 WinForms 的很大一部分是在 Mono 中实现的。为此,您需要在 Linux 下安装 Mono。但是,您可能会遇到兼容性问题,因为 Mono 不是 Microsoft 的成果,并且不受他们的正式支持。
回答by Joel Coehoorn
Probably GTK#would be the closest.
可能GTK#将是最接近的。
I know others have said mono, but that's not quite right. .Net is to mono as Microsoft's Java VM is to Sun's Java runtime. mono's not really in the same conceptual space as Swing. For that, GTK# is a closer match.
我知道其他人说过单声道,但这并不完全正确。.Net 之于 mono 就像微软的 Java VM 之于 Sun 的 Java 运行时一样。mono 与 Swing 不在同一个概念空间中。为此,GTK# 更接近。
回答by Greg Campbell
回答by devdimi
Windows.Forms is the standard library for developing GUI applications for .NET
Windows.Forms 是为 .NET 开发 GUI 应用程序的标准库
Despite of being very well supported on Windows, version 2.0 is fully implemented by Mono too, which makes it available on all platforms supported by Mono.
尽管在 Windows 上得到了很好的支持,但 Mono 也完全实现了 2.0 版,这使得它可以在 Mono 支持的所有平台上使用。
WPF on the other hand is is conceptually new library, for now it is fully supported mainly on Windows only and just a subset of it supported by Mono by their Silverlight implementation - Moonlight.
另一方面,WPF 是概念上的新库,目前它主要在 Windows 上得到完全支持,并且只有 Mono 通过其 Silverlight 实现 - Moonlight 支持它的一个子集。
If you are building application for productive cross-platform use and/or have conservative performance constraints go Windows Forms.
如果您正在构建用于高效跨平台使用的应用程序和/或有保守的性能限制,请使用 Windows 窗体。
If you want to experiment and learn something new or if you are developing new application for Windows go WPF. This is the new technology for client GUI applications.
如果你想尝试和学习新的东西,或者你正在为 Windows 开发新的应用程序,请使用 WPF。这是客户端 GUI 应用程序的新技术。
回答by Curtis
There's Eto.Forms(on github), which is an abstraction layer on top of WPF, WinForms, GTK, and MonoMac/Cocoa- so you can get a native UI on all platforms without having to re-implement for each platform. You don't have to suffer from lowest common denominator, since you can implement specifics for each platform (if desired, but not required).
有Eto.Forms(在 github 上),它是WPF、WinForms、GTK和MonoMac/Cocoa之上的抽象层- 因此您可以在所有平台上获得本机 UI,而无需为每个平台重新实现。您不必受制于最小公分母,因为您可以为每个平台实现具体细节(如果需要,但不是必需的)。
It has an advantage that it is pure .NET and only relies on OS-supplied dependencies, as opposed to using GTK or WxWidgets where you'd have to bundle the native binaries for various platforms.
它的优势在于它是纯 .NET 并且仅依赖于操作系统提供的依赖项,而不是使用 GTK 或 WxWidgets,在这种情况下,您必须为各种平台捆绑本地二进制文件。
回答by Edward Ned Harvey
For iOS, Android, and Windows Mobile, there is Xamarin.Forms. http://xamarin.com/formsThis is an abstraction layer that allows you to write cross-platform code, which binds to the native GUI toolkits under the hood.
对于 iOS、Android 和 Windows Mobile,有 Xamarin.Forms。 http://xamarin.com/forms这是一个抽象层,允许您编写跨平台代码,该代码绑定到引擎盖下的本机 GUI 工具包。
I am looking for more solutions like this - I care not only about mobile platforms, but also desktop platforms (windows, mac OSX, fedora/ubuntu/etc linux)
我正在寻找更多这样的解决方案 - 我不仅关心移动平台,还关心桌面平台(windows、mac OSX、fedora/ubuntu/etc linux)
回答by Brian Deragon
This is an older question, but as an update, a combination of Mono and Xamarin should work for your modern cross-platform needs.
这是一个较旧的问题,但作为更新,Mono 和 Xamarin 的组合应该可以满足您的现代跨平台需求。
http://www.mono-project.com/docs/gui/winforms/
http://www.mono-project.com/docs/gui/winforms/
Microsoft has just open-sourced .NET and is committing to bringing the .NET core to Linux and MacOS with their next version. Microsoft has also formed a close partnership with Mono and Xamarin, specifically to help with their Android and Linux libraries.
微软刚刚开源了 .NET,并承诺将 .NET 核心带到 Linux 和 MacOS 的下一个版本。微软还与 Mono 和 Xamarin 建立了密切的合作伙伴关系,专门帮助他们开发 Android 和 Linux 库。
回答by Melbourne Developer
There are plenty these days. It depends on what you are looking for. Hereis a detailed write-up about these three choice technologies. They are not the only technologies, but they have the most buzz around them right now.
这几天有很多。这取决于你在寻找什么。这是关于这三种选择技术的详细文章。它们不是唯一的技术,但它们现在最受关注。
C#, XAML Based, Microsoft owned Open Source, Supports Android, iOS, UWP, and more. Native rendering.
C#,基于 XAML,微软拥有开源,支持 Android、iOS、UWP 等。原生渲染。
C#, XAML Based, Open Source, Supports Android, iOS, UWP, and more. Native rendering.
C#,基于 XAML,开源,支持 Android、iOS、UWP 等。原生渲染。
C#, XAML Based, Open Source, Supports Linux, MacOS, Windows, and more. Pixel perfect rendering on each platform.
C#,基于 XAML,开源,支持 Linux、MacOS、Windows 等。每个平台上的像素完美渲染。