I have been developing Windows Forms 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.
If you are using .NET Core 3.0 and above, do the following steps and you are good to go: (I'm going to use .NET Core CLI, but you can use Visual Studio too):
md MyWinFormsApp
optional stepcd MyWinFormsApp
optional stepdotnet new sln -n MyWinFormsApp
optional step, but it's a good ideadotnet new winforms -n MyWinFormsApp
I'm sorry, this is not optionaldotnet sln add MyWinFormsApp
do this if you did step #3Okay, you can stop reading my answer and start adding code to the MyWinFormsApp
project. But if you want to work with Form Designer, keep reading.
MyWinFormsApp.csproj
file and change netcoreapp3.1
to net472;netcoreapp3.1
(if you are using netcoreapp3.0
don't worry. Change it to net472;netcoreapp3.0
)ItemGroup
Form
Form1.cs
After doing these steps, this is what you should end up with:
WinExe
net472;netcoreapp3.1
true
Form
Form1.cs
#if NETCOREAPP3_1
Application.SetHighDpiMode(HighDpiMode.SystemAware);
#endif
Now you can open the MyWinFormsApp
project using Visual Studio 2019 (I think you can use Visual Studio 2017 too, but I'm not sure) and double click on Form1.cs
and you should see this:
Okay, open up Toolbox (Ctrl + W, X) and start adding controls to your application and make it pretty.
You can read more about designer at Windows Forms .NET Core Designer.