How to put a text element in a Win2D - CanvasSvg at runtime (in UWP using CanvasSvgTextElement)?

94 Views Asked by At

A want to write text to a Win2d CanvasSvg document however I am unable to find any example at all on how to to this. I have already drawn some basic shapes but I'm stuck on text. The Class is described at: https://microsoft.github.io/Win2D/WinUI3/html/T_Microsoft_Graphics_Canvas_Svg_CanvasSvgTextElement.htm I'm not sure if the Win2d CanvasSvg even supports normal Svg text as an attempt to load a simple text file in svg (which worked ok with Chrome) failed to show anything when loaded (using the Win2D sample on the GitHub site & swapping the file for loading).

A google search for CanvasSvgTextElement gives only 7 results! As you can in the bit of code below, I am out of my depth!

        string myTest = "<text x=\"100\" y=\"100\" text=\"Hello World\" />"; 
        CanvasSvgTextElement testElement = new CanvasSvgTextElement( //something goes here - how to find?// );
        svgDocument.Root.CreateAndAppendTextChildElement( //what to put here ?//);
0

There are 0 best solutions below