This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
This article describes some of the new Windows Forms features and enhancements in .NET 8.
There are a few breaking changes you should be aware of when migrating from .NET Framework to .NET 8. For more information, seeBreaking changes in Windows Forms.
A new data binding engine was in preview with .NET 7, and is now fully enabled in .NET 8. Though not as extensive as the existing Windows Forms data binding engine, this new engine is modeled after WPF, which makes it easier to implement MVVM design principles.
The enhanced data binding capabilities make it simpler to fully utilize the MVVM pattern and employ object-relational mappers from ViewModels in Windows Forms. This reduces the amount of code in code-behind files. More importantly, it enables code sharing between Windows Forms and other .NET GUI frameworks like WPF, UWP/WinUI, and .NET MAUI. It's important to note that while the previously mentioned GUI frameworks use XAML as a UI technology, XAML isn't coming to Windows Forms.
TheIBindableComponent interface and theBindableComponent class drive the new binding system.Control implements the interface and provides new data binding capabilities to Windows Forms.
Button commands were in preview with .NET 7, and is now fully enabled in .NET 8. Similar to WPF, the instance of an object that implements theICommand interface can be assigned to the button'sCommand property. When the button is clicked, the command is invoked.
An optional parameter can be provided when the command is invoked, by the specifying a value for the button'sCommandParameter property.
TheCommand andCommandParameter properties are set in the designer through theProperties window, under(DataBindings), as illustrated by the following image.

Buttons also listen to theICommand.CanExecuteChanged event, which causes the control to query theICommand.CanExecute method. When that method returnstrue, the control is enabled; the control is disabled whenfalseis returned.
Visual Studio 2022 17.8 Introduces DPI-unaware designer tabs. Previously, the Windows Designer tab in Visual Studio ran at the DPI of Visual Studio. This causes problems when you're designing a DPI-unaware Windows Forms app. Now you can ensure that the designer runs at the same scale as you want the app to run, either DPI-aware or not. Before this feature was introduced, you had to run Visual Studio in DPI-unaware mode, which made Visual Studio itself blurry when scaling was applied in Windows. Now you can leave Visual Studio alone and let the designer run DPI-unaware.
You can enable the DPI-unaware designer for the Windows Forms project by adding<ForceDesignerDPIUnaware> to the project file, and setting the value totrue.
<PropertyGroup> <OutputType>WinExe</OutputType> <TargetFramework>net8.0-windows</TargetFramework> <Nullable>enable</Nullable> <UseWindowsForms>true</UseWindowsForms> <ImplicitUsings>enable</ImplicitUsings> <ForceDesignerDPIUnaware>true</ForceDesignerDPIUnaware> <ApplicationHighDpiMode>DpiUnawareGdiScaled</ApplicationHighDpiMode></PropertyGroup>Important
Visual Studio reads this setting when the project is loaded, and not when it's changed. After changing this setting, unload and reload your project to get Visual Studio to respect it.
High DPI rendering withPerMonitorV2 has been improved:
Correctly scale nested controls. For example, a button that's in a panel, which is placed on a tab page.
ScaleForm.MaximumSize andForm.MinimumSize properties based on the current monitor DPI settings.
Starting with .NET 8, this feature is enabled by default and you need to opt out of it to revert to the previous behavior.
To disable the feature, addSystem.Windows.Forms.ScaleTopLevelFormMinMaxSizeForDpi to theconfigProperties setting inruntimeconfig.json, and set the value to false:
{ "runtimeOptions": { "tfm": "net8.0", "frameworks": [ ... ], "configProperties": { "System.Windows.Forms.ScaleTopLevelFormMinMaxSizeForDpi": false, } }}Here are some other notable changes:
FolderBrowserDialog was improved, fixing a few memory leaks.System.Drawing source code was migrated to theWindows Forms GitHub repository.Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?