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.

ReplaceStringMap change is not reflected

See original GitHub issue

Description

ReplaceStringMap does not change the SVG.

Steps to Reproduce

var dict = new Dictionary<string, string>
{
    { "grey", "red" }
};
    var img = new SvgCachedImage
{
    Source = "results.svg",
};

img.ReplaceStringMap = dict;
img.ReloadImage();

			
StackTest.Children.Add( img );

On some SVG that looks like:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
    width='800'
    height='400'
    xmlns='http://www.w3.org/2000/svg'
    version='1.1'
    xmlns:xlink='http://www.w3.org/1999/xlink'>

    <defs>
        <rect id='left-lens' width='30' height='30' x='360' y='185'/>
        <rect id='right-lens' width='30' height='30' x='400' y='185'/>
        <mask id='mask'>
            <rect width='800' height='400' fill='white' />
            <use xlink:href='#left-lens'/>
            <use xlink:href='#right-lens'/>
        </mask>
    </defs>
    
    <rect width='800' height='400' fill='white' mask='url(#mask)'/>

    <use xlink:href='#left-lens' stroke-width='5' stroke='grey' fill='none'/>
    <use xlink:href='#right-lens' stroke-width='5' stroke='grey' fill='none'/>
</svg>

Expected Behavior

The grey stroke should be replace with red.

Actual Behavior

The grey stroke is still shown.

two grey rectangles

Basic Information

  • Version with issue: 2.4.1.823
  • Last known good version: I cant seem to find a version where this snippet works.
  • Platform: Android

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
EmilAlipievcommented, Sep 14, 2018

@daniel-luberda I found the problem in my case. I am using converter as show below

<ffimageloadingsvg:SvgCachedImage  Style="{StaticResource IconStyle}"     Source="resource://App1.level.svg"                 
                  ReplaceStringMap="{Binding AssignButton, Converter={StaticResource AppColorToButtonConverter}}" 
                  />

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
              
            var ReplaceMap = new Dictionary<string, string>()
                {
                    { "#FFFFFF", "#3F51B5" }
                };

            return ReplaceMap;
          
        }

If i define ReplaceStringMap before Source property, it works but other way around like above doesnt work. Please find the repro attached. in the repro change order of source and ReplaceStringMap properties, you will see that it works App1.zip

0reactions
EmilAlipievcommented, Sep 14, 2018

hey it is strange behavior indeed. I have some svgs ReplaceStringMap works but attached svg doesnt work. it looks like same problem. did you find a solution for this?

I am also doing like

var dict = new Dictionary<string, string> { { “#FFFFFF”, “#2196F3” } };

<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="32" width="32" viewBox="0 0 32 32">
  <g>
    <path id="path1" transform="rotate(0,16,16) translate(0,4.10000038146973) scale(1,1)" fill="#FFFFFF" d="M0,17.599985L5.0999756,17.599985 5.0999756,23.799999 0,23.799999z M9,12.299994L14.099976,12.299994 14.099976,23.799999 9,23.799999z M18,6.400027L23,6.400027 23,23.799999 18,23.799999z M26.899994,0L32,0 32,23.799999 26.899994,23.799999z" />
  </g>
</svg>

for example same code works for the below svg

<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24">
  <g>
    <path id="path1" transform="rotate(0,12,12) translate(0.1680006980896,0) scale(0.75,0.75)  " fill="#FFFFFF"  
  </g>
</svg>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Xamarin.Forms set Button ImageSource as ffimageloading ...
But it's not working. Moreover I can't make working this syntax. Source="{resource://fullname.svg, Converter={StaticResource ...
Read more >
FFImageLoading - Fast & Furious Image Loading changelog
Changes. If both downsampling width / height is set, then height is ignored (better memory cache hit rate). This was eg. iOS package ......
Read more >
SVG image is not displaying in android in xamarin.forms
The issue is that background is not changing on Pointer Enter Event. Instead it changes on Pointer Exit. Any help will be appreciated!...
Read more >
Excluding some urls for the STREAM conversion
I have the following iRule that converts http to https for external users only as defined on the internal_net However, when the page...
Read more >
Xamarin.Forms set Button ImageSource ... - appsloveworld.com
Updated original image resource extension class for Xamarin. OP's class had two issues: Missing ContentProperty attribute which allows to skip "Source" ...
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