ListBox.DefaultItemHeight is no longer used as the default item height for the ListBox control because now item height is proportional to the current application font. This change is necessitated by the introduction of the new default font for WinForms controls in .NET Core 3.1.
Version
.NET 8 Preview 2
Previous behavior
Applications referencing ListBox.DefaultItemHeight constant compiled with no warnings related to this value.
New behavior
Applications referencing ListBox.DefaultItemHeight constant will compile with the following warning:
WFDEV004:ListBox.DefaultItemHeight` constant is no longer used as the default item height. Default item height is now scaled according to the application default font.
Type of breaking change
[ ] Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load or execute, and if so, require recompilation.
[X] Source incompatible: When recompiled using the new SDK or component or to target the new runtime, existing source code may require source changes to compile successfully.
[ ] Behavioral change: Existing binaries may behave differently at run time.
Reason for change
The new default ListBox item height value is calculated dynamically, based on the application font.
Description
ListBox.DefaultItemHeight
is no longer used as the default item height for the ListBox control because now item height is proportional to the current application font. This change is necessitated by the introduction of the new default font for WinForms controls in .NET Core 3.1.Version
.NET 8 Preview 2
Previous behavior
Applications referencing
ListBox.DefaultItemHeight
constant compiled with no warnings related to this value.New behavior
Applications referencing
ListBox.DefaultItemHeight
constant will compile with the following warning: WFDEV004:
ListBox.DefaultItemHeight` constant is no longer used as the default item height. Default item height is now scaled according to the application default font.Type of breaking change
Reason for change
The new default
ListBox
item height value is calculated dynamically, based on the application font.Recommended action
Use
Control.DefaultFont.Height
values instead.Feature area
Windows Forms
Affected APIs
ListBox.DefaultItemHeight
Associated WorkItem - 63465