Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Path.Fill and Path.Stroke not working when set with DynamicResource #11907

Closed
KaeTar opened this issue Aug 24, 2020 · 15 comments · Fixed by #12761
Closed

Path.Fill and Path.Stroke not working when set with DynamicResource #11907

KaeTar opened this issue Aug 24, 2020 · 15 comments · Fixed by #12761
Labels
a/brushes a/style blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. t/bug 🐛
Milestone

Comments

@KaeTar
Copy link

KaeTar commented Aug 24, 2020

Description

I have quite a few paths in my application. When I upgraded from Xamarin.Forms 4.7.0.1260 to 4.8.0.1269 all of my paths disappeared and were no longer painting. I tracked it down to the use of Fill="{DynamicResource xxxx}" and Stroke="{DynamicResource xxxx}". I am using a resource dictionary for colors that gets swapped out when the theme changes. If I set the path or the stroke with a dynamic resource that is either a Color or a SolidColorBrush there are no errors however it does not set the color at all and the path never renders visible. If I set the Fill or Stroke with a static color like Fill="DarkBlue" it works fine. I am rolling back as this is not going to work for me.

Steps to Reproduce

  1. Create a ResourceDictionary with an entry for DarkBlue
  2. Load that dictionary in the app.xaml
  3. Create a Path and set the Fill="{DynamicResource myPathColor}"
  4. Notice that the color never gets applied
  5. Set the path parameter to Fill="DarkBlue"
  6. Notice that it works fine when set directly

Expected Behavior

I would expect that using a SolidColorBrush from a resource dictionary with DynamicResource would correctly apply the color like it does everywhere else.

Actual Behavior

Color is never applied and path remains invisible.

Basic Information

  • Version with issue: 4.8.0.1269
  • Last known good version: 4.7.0.1260
  • IDE: Visual Studio 2019 16.7.2
  • Platform Target Frameworks:
    • iOS: 13.6
    • Android: 9.0 api 28
    • UWP: NA
@samhouts samhouts added this to New in Triage Aug 24, 2020
@jsuarezruiz jsuarezruiz added a/brushes a/style s/unverified New report that has yet to be verified t/bug 🐛 labels Aug 25, 2020
@jsuarezruiz
Copy link
Contributor

Is the same issue or related with:

#11691
#11911

@jsuarezruiz jsuarezruiz moved this from New to Ready For Work in Triage Aug 25, 2020
@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Aug 25, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 25, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 25, 2020
@samhouts samhouts moved this from Ready For Work to Needs Estimate in Triage Aug 26, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@rmarinho rmarinho added the blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. label Nov 6, 2020
@rmarinho rmarinho added this to the 5.0.0 milestone Nov 6, 2020
@rmarinho rmarinho added this to To do in vNext+1 (5.0.0) via automation Nov 6, 2020
Triage automation moved this from Needs Estimate to Closed Nov 11, 2020
vNext+1 (5.0.0) automation moved this from To do to Done Nov 11, 2020
rmarinho pushed a commit that referenced this issue Nov 11, 2020
#11911 fixes #11691

* Propagate BC to Brush childrens

* Added Brush unit test to check if propagate the bc correctly

* Added another repro sample

* Fix the issue

* Added brush parent unit test
@shalinasanga
Copy link

is this fixed ? tried on Xamarin.Forms 5.0.0.1709-pre4 not working with Binding
<Path HorizontalOptions="Center" VerticalOptions="Center" Fill="{Binding StatusColor}" Stroke="Black" StrokeThickness="1" Aspect="Uniform" HeightRequest="38" WidthRequest="38" Data="M 100 100 a 50 50 0 1 0 0.00000001 0 "/>

@sthch
Copy link

sthch commented Nov 18, 2020

is this fixed ? tried on Xamarin.Forms 5.0.0.1709-pre4 not working with Binding
<Path HorizontalOptions="Center" VerticalOptions="Center" Fill="{Binding StatusColor}" Stroke="Black" StrokeThickness="1" Aspect="Uniform" HeightRequest="38" WidthRequest="38" Data="M 100 100 a 50 50 0 1 0 0.00000001 0 "/>

I've got the same problem, Xamarin.Forms 5.0.0.1709-pre4
<Ellipse WidthRequest="6" HeightRequest="6" HorizontalOptions="Center" VerticalOptions="Start" Stroke="{StaticResource AccentColor}" />

@KaeTar
Copy link
Author

KaeTar commented Nov 18, 2020

is this fixed ? tried on Xamarin.Forms 5.0.0.1709-pre4 not working with Binding
<Path HorizontalOptions="Center" VerticalOptions="Center" Fill="{Binding StatusColor}" Stroke="Black" StrokeThickness="1" Aspect="Uniform" HeightRequest="38" WidthRequest="38" Data="M 100 100 a 50 50 0 1 0 0.00000001 0 "/>

One of the big changes I noticed was that Stroke and Fill changed from Color to SolidColorBrush. Are you trying to bind to a Color or a SolidColorBrush?

@sthch
Copy link

sthch commented Nov 19, 2020

is this fixed ? tried on Xamarin.Forms 5.0.0.1709-pre4 not working with Binding
<Path HorizontalOptions="Center" VerticalOptions="Center" Fill="{Binding StatusColor}" Stroke="Black" StrokeThickness="1" Aspect="Uniform" HeightRequest="38" WidthRequest="38" Data="M 100 100 a 50 50 0 1 0 0.00000001 0 "/>

One of the big changes I noticed was that Stroke and Fill changed from Color to SolidColorBrush. Are you trying to bind to a Color or a SolidColorBrush?

Yes, I'm trying to bind it to a Color.
Change the code as followings and it works.
<Ellipse WidthRequest="6" HeightRequest="6" HorizontalOptions="Center" VerticalOptions="Start"> <Ellipse.Stroke> <SolidColorBrush Color="{StaticResource AccentColor}" /> </Ellipse.Stroke> </Ellipse>

@shalinasanga
Copy link

is this fixed ? tried on Xamarin.Forms 5.0.0.1709-pre4 not working with Binding
<Path HorizontalOptions="Center" VerticalOptions="Center" Fill="{Binding StatusColor}" Stroke="Black" StrokeThickness="1" Aspect="Uniform" HeightRequest="38" WidthRequest="38" Data="M 100 100 a 50 50 0 1 0 0.00000001 0 "/>

One of the big changes I noticed was that Stroke and Fill changed from Color to SolidColorBrush. Are you trying to bind to a Color or a SolidColorBrush?

tried using SolidColorBrush as below, no luck. StatusColor returns hex
<Path Stroke="Black" StrokeThickness="1" Aspect="Uniform" HeightRequest="35" WidthRequest="35" Data="M 100 100 a 50 50 0 1 0 0.00000001 0 "> <Path.Fill> <SolidColorBrush Color="{Binding StatusColor}"/> </Path.Fill> </Path>

@AdrianoRochedo
Copy link

AdrianoRochedo commented Jan 29, 2021

not working on Forms 5.0.0.1931 !!!
tested on UWP

@Jack-Paul
Copy link

Still, the issue is not fixed, I have checked with 5.0.0.2012.
when I bind the path fill color or stroke color to a property, the path disappears.
I also tried using SolidColorBrush, still no luck.

Please fix this issue or provide some workaround!!!

@JimmyKDev
Copy link

JimmyKDev commented Mar 8, 2021

I also have 5.0.0.2012 installed. Binding Stroke and Fill to properties is not working e.g. Fill={Binding ShapeFillColor}
FYI, the ShapeFillColor is returning a color name such as Green etc. Just in case this is a value conversion issue.

@EmilAlipiev
Copy link
Contributor

why was that closed? it is not working.

@Aston13
Copy link

Aston13 commented Apr 28, 2021

Encountered this issue today with binding a color to a Line Stroke:

    string StateColor = "Green";

    <Line Stroke="{Binding StateColor}" Y1="100" StrokeThickness="5"/>

Line does not appear to be visible. However, setting the string directly will work:

    <Line Stroke="Green" Y1="100" StrokeThickness="5"/>

@lperezj
Copy link

lperezj commented May 28, 2021

I have the same problem. I dont know why its Closed. ???¿?¿? becouse its not working.

<Style x:Key="StatusIconBase" TargetType="Path"> I try in the same ResourceDictionary or in other xaml but is not working. #FF787878 and with ColorBrush

@Jack-Paul
Copy link

Why people closing this if it's still not fixed.

@Jack-Paul
Copy link

Opened as a new bug here.
#14418

@Januplus
Copy link

issue still not fixed

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/brushes a/style blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. t/bug 🐛
Projects
Triage
  
Closed
Development

Successfully merging a pull request may close this issue.