ReplaceStringMap doesn't work
See original GitHub issueI’d like to replace a color within an SVG file.
As far as I found out, ReplaceStringMap is the way to go.
The following example should display a blue rectangle, but it’s red (as defined in the SVG file):
The SVG file contains a red rectangle:
<svg viewBox="0 0 24 24">
<rect fill="#ff0000" width="24" height="24" />
</svg>
Code to display the image - note the ReplaceStringMap should replace red by blue:
public partial class MainPage : ContentPage {
public MainPage() {
var layout = new StackLayout();
layout.Children.Add(new SvgCachedImage {
Source = "resource://Foo.Images.test.svg",
ReplaceStringMap = new Dictionary<string, string> { { "ff0000", "0000ff"} },
WidthRequest = 98, HeightRequest = 98
});
this.Content = layout;
}
The result is a red rectangle instead of a blue one. Am I doing something wrong?
(PS.: I also tried calling ReloadImage() but that didn’t help either)
Xamarin.FFImageLoading.Svg version is 2.2.25.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
FFImageLoading Xaml ReplaceStringMap SvgCachedImage
Hello Xamarin,. I would like to change text property of an SVG image at runtime. I use FFImageLoading library on a forms application....
Read more >Does not work Regex for multiple string split in java?
I want to split string by "[11]" , "[86]" , "[87]" Tried following code but does not work. void testSplit() { StringBuilder message...
Read more >Stream::Replace Will Not Work
I am able to cause failures by replacing with STREAM::expression but, again, any replacement attempts with STREAM::replace will not work.
Read more >ounit2 2.2.3 · OCaml Package
to rename oUnit to ounit was not working on Windows and MacOSX because their filesystems are case insensitive and the ... replace String.map...
Read more >FFImageLoading - Fast & Furious Image Loading changelog
StartNew for each task (not for batch of tasks as previously) ... This was really important to me, as it will allow to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes all projects use the same version.
It looks like the order in which the properties are set matters:
This one does not work (image stays red):
This one works (image turns blue):
So it seems like the replacement does not work when the ReplaceStringMap property is set after the Source property.
For me it works on both platforms (iOS and Android):