Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to add SVG in Blazor/razor file

$
0
0

I have a Blazor app (.Net 3.1 Core) that generate an SVG image. It is generated like any other HTML using razor/Blazor syntax. The problem is when generating SVG <text> elements. I have tried

<text x="0">Some text</text>

and this results in invalid syntax since is special in razor files. I have also tried

@:<text x="0">Some text</text>

which is accepted by razor, but this results in tags getting removed and attributes rendered as normal text instead of SVG tags.

How do I write an SVG <text> element in razor syntax? I don't want to revert to C# and HtmlString etc.

Update: Missing key point here was that I used it inside a @foreach, which I first didn't think was relevant.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>