Is it possible to make desktop GUI application in

2020-02-07 16:08发布

I have been developing WinForms programs for few years. I am now looking into .NET Core (including ASP.NET Core MVC). I am searching for the new GUI desktop technology. In Visual Studio 2015 update 3 I can't see any option to make a GUI app in .NET Core. What am I missing?

14条回答
Melony?
2楼-- · 2020-02-07 16:16

Yes, it is possible.

.NET Core doesn't have any components for native GUI application out of the box. However, there is a NuGet package for it that is called Electron.NET, as per Gregor Biswanger's answer.

Electron is a framework that allows you to build native GUI applications on top of Node.js. Electron.NET is a NuGet package that allows you to utilise Electron and Node.js from within your .NET Core code.

The good news is that you don't have to learn JavaScript, Electron or Node.js in order to be able to use the NuGet package. JS files do run inside your application, but they get automatically generated by the build process.

All you do is build a pretty standard ASP.NET Core MVC app. The only difference is that, instead of running in the browser, it runs as a native windowed app. Besides just a few lines of code specific to the Electron.NET package, you won't need to learn anything above ASP.NET Core MVC.

This page provides a tutorial on how to use it. It also contains some links to sample code repositories.

查看更多
家丑人穷心不美
3楼-- · 2020-02-07 16:19

One option would be using Electron with JavaScript, HTML, and CSS for UI and build a .Net Core console application that will self-host a web api for back-end logic. Electron will start the console application on background that will expose a service on localhost:xxxx.

This way you can implement all back-end logic using .Net to be accessible through HTTP requests from JavaScript.

Take a look at this post, it explains how to build a cross-platform desktop application with Electron and .Net Core and check code on github

查看更多
迷人小祖宗
4楼-- · 2020-02-07 16:19

For creating console-based UI, you can use gui.cs. It is open-source (from Miguel, creator of Xamarin), and runs on .Net core on Windows, Linux & MacOs.

It has the following components:

  • Buttons
  • Labels
  • Text entry
  • Text view
  • Time editing field
  • Radio buttons
  • Checkboxes
  • Dialog boxes
    • Message boxes
  • Windows
  • Menus
  • ListViews
  • Frames
  • ProgressBars
  • Scroll views and Scrollbars
  • Hexadecimal viewer/editor (HexView)

Sample screenshot

gui.cs sample output screenshot

查看更多
唯我独甜
5楼-- · 2020-02-07 16:26

It is now possible to use Qt/QtQuick/QML with .NET Core, using Qml.Net.

It is highly performant (not "pinvoke chatty"), fully featured and works across Linux/OSX/Windows.

Check out my blog post to see how it compares to the other options out there currently.

PS: I'm the author.

查看更多
放我归山
6楼-- · 2020-02-07 16:28

You were not missing anything. MS shipped no reasonable way to create GUI applications directly using .Net Core until .Net Core 3, though UWP (Universal Windows Platform) is partially built on top of .Net Core.

.Net Core 3.0 includes support for Winforms and WPF, though it is Windows-only.

For cross platform options that have come up in the past 2 years, see other answers.

查看更多
ゆ 、 Hurt°
7楼-- · 2020-02-07 16:34

.NET Core 3 will have support for creating Windows Desktop Applications. I watched a demo of the technology yesterday during the .NET Conference. This is the only blog post I could find, but does illustrate the point: https://blogs.msdn.microsoft.com/dotnet/2018/05/07/net-core-3-and-support-for-windows-desktop-applications/

查看更多
登录 后发表回答