Description
Rationale:
We recently discussed and implemented a new method named SetDefaultFont
on the Application
type, which allows the User to, well, do exactly this: Set a Default font. The primary motivation was for migration of legacy Framework WinForms apps, which had pixel-perfect Form designs based on the previous standard font, to still work in .NET. without completely redoing the layout.
While having this method is important, the means to apply it doesn't go far enough: Our concern is especially for VB (@KathleenDollard) that we will have problems in the future to find a feasible way to apply further default values, should we need them. And we most likely will.
While we could introduce an other application event ApplyDefaultFont
for the Application Framework, our concern is, that we wouldn't stop introducing more and more patterns like this, and this would extremely affect the clarity and ultimately the discoverability of new APIs around new default values, since we would flood VB with new "ApplyDefaultxxx" events over the time.
Introducing ApplicationDefaults
, Defaults
Property and ApplyApplicationDefaults
event.
Rather, we'd like to introduce for VB a new Application Framework event called ApplyApplicationDefaults
. This event would provide access to a Defaults Property of a new type ApplicationDefaults
, and via a series of SetDefaultXXX
extension methods, we could feed the internal collection of Defaults
Values of the Application
object/type in a type safe and easily extendable way.
This would also mean, we would introduce a Defaults
Property of type ApplicationDefaults
on the Application
type/object.
Setting default values (of which only DefaultFont via the extension method SetDefaultFont
) would exist as the first in the .NET 6 timeframe) in C# would be done like this:
In VB, we'd be introducing the ApplyApplicationDefaults
event, and it usage would be similar to applying the HighDpiMode
via the ApplyHighDpiMode
event of the VB Application Framework:
At the same time, we would need to apply the changes for setting the Defaults for the templates in VB and in C#.
#3705 already has the implementation for this proposal.