WinUI 3: LinearGradientBrush and RadialGradientBrush don't both inherit from GradientBrush
See original GitHub issueDescribe the bug
In WPF both LinearGradientBrush
and RadialGradientBrush
inherit from the GradientBrush
base class. In WinUI this is not the case. I can understand in WinUI 2 that this was an added feature, but with WinUI 3 and access to modify the underlying structures, it seems like better alignment should be achievable.
Having them inherit from the same base class makes it easier to maintain consistency and more easily switch brushes between linear and radial variants by adding the additional parent properties. It also means that library owners can create extensions or helpers that target the base GradientBrush
class that will work with both classes (for instance Animation helpers).
Expected behavior Both Gradient Brushes should share the same base class.
Version Info
NuGet package version: Microsoft.WinUI 3.0.0-preview3.201113.0
Additional Info WinUI/Toolkit Class Links:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top GitHub Comments
This isn’t something that we are going to be able to change. LinearGradientBrush and RadialGradientBrush do not share any implementation. LinearGradientBrush is implemented natively in Microsoft.UI.Xaml.dll, RadialGradientBrush is implemented in Microsoft.UI.Xaml.Controls.dll and is based on XamlCompositionBrush. Creating a new GradientBrush base class would require reimplementing one or both of these brushes from scratch. There would be some nice benefits to do this, but not enough to justify the cost.
Bump, related to #7967 as well.