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 1

    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 4

    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.