Skip to content

GradientBrushes are not supported on Shape.Stroke #21983

@crhalvorson

Description

@crhalvorson

Description

When applying a Linear or Radial Gradient Brush to the Stroke property of a Shape (Path, or one of the prebuilt shapes such as Ellipse), the color applied to the Stroke is only the first color defined in the gradient as if it were a SolidColorBrush. A GradientBrush in a Fill or Background has worked as expected.

I could not find a place where this was specifically documented (and this was working in Xamarin.Forms) so I am logging this as a bug. I did find some potentially related issues but they did not specifically address the issue of a gradient on the Stroke property.

Screenshot from the repro app linked below:
image

I found this on MAUI 8.0.7 but tested 8.0.20 as well.

Steps to Reproduce

  1. Create a new .NET MAUI App
  2. Define a LinearGradient with distinct colors
  3. Create an Ellipse and set it with sufficient border/stroke thickness to be able to see the change in gradient. Use the same gradient for Fill and Stroke
  4. Note that the gradient is applied to the Fill, but not the Stroke

Link to public reproduction project repository

https://github.com/crhalvorson/MauiPathGradientRepro

Version with bug

8.0.20 SR4

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

iOS 17.2, Android 14

Did you find any workaround?

Border.Stroke supports a GradientBrush and can accept a StrokeShape that contains a Path or other shape (see reproduction repo for an example).

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-drawingShapes, Borders, Shadows, Graphics, BoxView, custom drawingdelightermigration-compatibilityXamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convertplatform/androidplatform/ioss/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/enhancement ☀️New feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions