Search code examples
wpfpathexpression-blendshapes

Is there a way to programmatically convert other Xaml elements to path elements?


In Blend, it is possible to convert certain Xaml elements to Path, using Object->Path->Convert to Path option.

Is there some API to do the same programmatically, in a WPF application?

Thanks


Solution

  • Having dived into the source-code of Expression Blend with DotPeek (for research purposes of course), I can say that the Convert to Path API is not exposed in a useful way.

    Internally it uses a number of private methods to convert RichTextBox content, TextBlocks, TextBoxes and simply geometry.

    The only external method is in Microsoft.Expression.DesignSurface.Geometry:

    public static PathGeometry[] ConvertToPathGeometries(SceneElement element)
    

    But the parameter SceneElement is a type used only within Expression blend and has a huge number of dependencies. There appears no easy way to create SceneElements for your own Silverlight objects outside of Expression Blend. You could probably execute the functionality as a Blend add-in but I don't see you getting it working in a stand-alone application.

    It was an interesting exercise, but unsuccessful. Sorry.