Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Does anyone know how ReplaceStringMap works on SvgCachedImage?

JimBMJimBM GBMember ✭✭

I can't find any demos, I've tried a few things. But it doesn't seem to work with what I've tried.
I'm trying to change the fill color property on an SVG.

Best Answer

  • JimBMJimBM GBMember ✭✭
    Accepted Answer

    You have to reload too
    Dictionary<string, string> Map = new Dictionary<string, string>();
    Map.Add("132D48", "ff0000");
    Img.ReplaceStringMap = Map;
    Img.ReloadImage();

Answers

  • JimBMJimBM GBMember ✭✭
    Accepted Answer

    You have to reload too
    Dictionary<string, string> Map = new Dictionary<string, string>();
    Map.Add("132D48", "ff0000");
    Img.ReplaceStringMap = Map;
    Img.ReloadImage();

  • DanielLDanielL PLInsider ✭✭✭✭

    BTW: Newest version auto reloads when ReplaceStringMap property is changed.

  • AbelGarciaSaizAbelGarciaSaiz USMember ✭✭
    edited November 2017

    I don't know what i'm doing wrong but I can not get it to work @DanielL
    For this svg (got it from project wiki)

    How should i use ReplaceStringMap to change color, for example, to red?
    i tried Map.Add("fill", "#ff0000") Map.Add("fill", "red") ... and color remains the same or changes to black although i set it to red

    Thanks in advance

  • DanielLDanielL PLInsider ✭✭✭✭
    edited November 2017

    It's just a simple text replacement, so if you have somewhere a #cccccc string value in your svg, then you just do:

    Map.Add("#cccccc", "#someothercoloryouwanttochangeto")

  • AbelGarciaSaizAbelGarciaSaiz USMember ✭✭

    Perfects, it works now. Thanks

Sign In or Register to comment.