我想知道是否有一种工具可以将“M 0 0 l 10 10”之类的路径数据转换为等效的线/曲线段代码。
目前我正在使用:
string pathXaml = "<Path xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" Data=\"M 0 0 l 10 10\"/>";
Path path = (Path)System.Windows.Markup.XamlReader.Load(pathXaml);
在我看来,调用 XamlParser 比显式创建线段慢得多。然而,手动转换很多路径是非常乏味的。
最佳答案
关于WPF,将 Path.DataProperty 转换为 Segment 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2436043/