简体   繁体   English

XAML-如何以编程方式从迷你标记创建路径?

[英]XAML - How do I programmatically create a Path from mini-markup?

I have some mini markup describing a shape. 我有一些描述形状的迷你标记。 In XAML, I can use this string directly in XAML or via a binding or resource, but how can I programmatically use this markup? 在XAML中,我可以直接在XAML中或通过绑定或资源使用此字符串,但如何以编程方式使用此标记? The problem is that no geometry or shape API in the framework seems to accept a string. 问题在于,框架中的任何几何或形状API似乎都不接受字符串。

I remember struggling with this same problem in 2008. Has nothing changed? 我记得在2008年遇到同样的问题。没有改变吗?

Ho hum. I found this workaround. 我找到了解决方法。

Path o = (Path)XamlReader.Load(String.Format(@"<Path xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Data=""{0}"" />", pathData));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM