In Blend, it is possible to convert certain Xaml elemen开发者_如何学JAVAts to Path, using Object->Path->Convert to Path option.
Is there some API to do the same programmatically, in a WPF application?
Thanks
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.
精彩评论