For some reason Path inspection functionality has been removed on the UWP. I've managed to cobble together a solution using SkiaSharp (I also considered Win2D, however SkiaSharp supports more platforms).
In my path generating code, where I previously used the GetFlattenedGeometry
I do the following:
// using SkiaSharp;
var path = SKPath.ParseSvgPathData(mySvgLikePathString);
var measure = SKPathMeasure(path);
var pathLength = measure.Length;
// get the position and tangent half way along the path
measure.GetPositionAndTangent(0.5 * pathLength, out SKPoint pos, out SKPoint tangent);
// do some magic to generate the SVG-like path in here and return the string representation
return GenerateSuperSpecialPath(path, pos, tangent);
Once I have the path string I can put it in my ViewModel and bind it in the template:
<Path Data={Binding MyPathString, Converter={StaticResource StringToGeometryConverter}} />
The converter looks like this:
public class StringToGeometryConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var pathStr = "<Geometry xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">" + (string)value + "</Geometry>";
return (Geometry)XamlReader.Load(pathStr);
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new InvalidOperationException("Cannot convert from Geometry to string");
}
}
Possibly not the most performant solution but it works and I don't notice any serious delays when drawing the paths.