Xamarin.forms: Polygon Shape doesn't work with DynamicResource color binding

Created on 7 Aug 2020  路  9Comments  路  Source: xamarin/Xamarin.Forms

Description

Updating to XF 4.8 from 4.7 the DynamicResource fill color binding on the Polygon shape is no longer recognized. It still works with a fixed color.

Steps to Reproduce

  1. Bind a DynamicResource color to the fill color on a Polygon shape in XAML.

Expected Behavior

The DynamicResource color binding is used to fill the Polygon.

Actual Behavior

The Polygon is not drawn at all.

Basic Information

  • Version with issue: Xamarin Forms 4.8.0.1269
  • Last known good version: 4.7.0.1260
  • IDE: Visual Studio for Mac 8.7
  • Platform Target Frameworks:

    • iOS: 13.6 (13.20.2.2)

    • Android: 10 (10.3.1.4)

  • Affected Devices: iOS Simulator, Samsung SM-T395

Screenshots

4.7:
Simulator Screen Shot - iPhone 11 - 2020-08-07 at 14 48 00

4.8:
Simulator Screen Shot - iPhone 11 - 2020-08-07 at 14 48 50

Reproduction Link

PolygonDynamicColor.zip

4.8.0 shapes blocker 3 bug

Most helpful comment

@bdgza Thanks for the new modified sample. Now I see the issue!. Will answer here when I have the fix.

All 9 comments

@StephaneDelcroix or @jsuarezruiz ?

The type supported by the Shapes Fill and Stroke properties in Xamarin.Forms 4.8 is a Brush (SolidColorBrush, LinearGradientBrush, or RadialGradientBrush) instead of a Color.
The first case works because there is a TypeConverter, but in the second, using a Color type, it is not working. Changing the Color resource by a SolidColorBrush fixes the problem.

@jsuarezruiz so you'd like TypeConverters to be applied with DynamicResource, or any kind of Binding too ?

I define a SolidColorBrush entry in my App.xaml and reference this Brush in my Polygon Fill instead of the Color. But then setting the Color for my SolidColorBrush has the same problem as setting the Color directly.

I can only use a fixed color or StaticResource Color, as soon as I change the Brush Color to a DynamicResource Color it doesn't render the Polygon.

Could you take a look to this modified sample:
PolygonDynamicColor.zip
?

Captura de pantalla 2020-08-17 a las 14 28 48

I took a look, but what if I wanted to do it like how it is in this modified modified sample:
PolygonDynamicColor.zip

@bdgza Thanks for the new modified sample. Now I see the issue!. Will answer here when I have the fix.

I think this needs reopened @rmarinho. I've posted a comment on #12836 describing more but if the color dynamically changes the polygon shape does not change color. It is behaving like a StaticResource instead of a DynamicResource.

@BurkusCat Thanks for the feedback, I will review the issue changing the DynamicResource.

Was this page helpful?
0 / 5 - 0 ratings