question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WinUI 3: LinearGradientBrush and RadialGradientBrush don't both inherit from GradientBrush

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kmahonecommented, Aug 9, 2023

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.

0reactions
michael-hawkercommented, Jul 28, 2023

Bump, related to #7967 as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

LinearGradientBrush Class (Windows.UI.Xaml.Media)
LinearGradientBrush is a type of Brush that is used for many possible UI properties that use a Brush to fill some or all...
Read more >
RadialGradientBrush Class (Microsoft.UI.Xaml.Media)
RadialGradientBrush paints an area with a radial gradient. A center point defines the origin of the gradient, and an ellipse defines the outer...
Read more >
Can't Animate RadialGradientBrush GradientStop with ...
Able to animate gradient color of a RadialGradientBrush . ... WinUI 3: LinearGradientBrush and RadialGradientBrush don't both inherit from ...
Read more >
Get Radial Gradient in UWP XAML
Linear Gradient in UWP XAML works fine but I need to convert it to Radial Gradient brush. Here is my current UWP XAML...
Read more >
gradient - Is there a MergedGradientBrush in wpf?
Short answer, there is no way to "merge" two different gradient brushes into one. However, there are workarounds that will get the job...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found