如何在 Windows Phone 8 中为路径元素动态设置几何数据?
How to set a Geometry data dynamically for a Path element in Windows Phone 8?
我想为路径 (UIElement) 设置数据,我使用了这些代码:
string arrSound = "M153.1,2.6L54.5,74.9H15.9C7.1,74.9,0,82.3,0,91.3v43.7c0,9,7.2,16.4,15.9,16.4h38.5l98.7,72.3"+
"c7.2,5.3,12.9,2.2,12.9-6.8V9.4C166.1,0.4,160.3-2.7,153.1,2.6L153.1,2.6z M153.1,2.6 M269.1,113.7l37.2-38.2c3.1-3.2,3.1-8.5,0-11.6l-7.5-7.7c-3.1-3.2-8.2-3.2-11.3,0l-37.2,38.2l-36.9-37.9"+
"c-3.1-3.2-8.2-3.2-11.3,0l-7.5,7.7c-3.1,3.2-3.1,8.5,0,11.6l36.9,37.9l-36.9,37.9c-3.1,3.2-3.1,8.5,0,11.6l7.5,7.7"+
"c3.1,3.2,8.2,3.2,11.3,0l36.9-37.9l36.9,37.9c3.1,3.2,8.2,3.2,11.3,0l7.5-7.7c3.1-3.2,3.1-8.5,0-11.6L269.1,113.7z M269.1,113.7";
string frontCode = "<Path xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Data='";
System.Windows.Shapes.Path geo;
geo = XamlReader.Load(frontCode + arrSound + "'/>") as System.Windows.Shapes.Path;
vectorSound.Data = geo.Data;
但是当我运行进入这一行时vectorSound.Data = geo.Data
出现了错误。
如果你只解析一个 XAML 几何图形,它应该可以工作:
var xaml = "<Geometry xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">"
+ arrSound + "</Geometry>";
vectorSound.Data = (Geometry)XamlReader.Load(xaml);
我想为路径 (UIElement) 设置数据,我使用了这些代码:
string arrSound = "M153.1,2.6L54.5,74.9H15.9C7.1,74.9,0,82.3,0,91.3v43.7c0,9,7.2,16.4,15.9,16.4h38.5l98.7,72.3"+
"c7.2,5.3,12.9,2.2,12.9-6.8V9.4C166.1,0.4,160.3-2.7,153.1,2.6L153.1,2.6z M153.1,2.6 M269.1,113.7l37.2-38.2c3.1-3.2,3.1-8.5,0-11.6l-7.5-7.7c-3.1-3.2-8.2-3.2-11.3,0l-37.2,38.2l-36.9-37.9"+
"c-3.1-3.2-8.2-3.2-11.3,0l-7.5,7.7c-3.1,3.2-3.1,8.5,0,11.6l36.9,37.9l-36.9,37.9c-3.1,3.2-3.1,8.5,0,11.6l7.5,7.7"+
"c3.1,3.2,8.2,3.2,11.3,0l36.9-37.9l36.9,37.9c3.1,3.2,8.2,3.2,11.3,0l7.5-7.7c3.1-3.2,3.1-8.5,0-11.6L269.1,113.7z M269.1,113.7";
string frontCode = "<Path xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' Data='";
System.Windows.Shapes.Path geo;
geo = XamlReader.Load(frontCode + arrSound + "'/>") as System.Windows.Shapes.Path;
vectorSound.Data = geo.Data;
但是当我运行进入这一行时vectorSound.Data = geo.Data
出现了错误。
如果你只解析一个 XAML 几何图形,它应该可以工作:
var xaml = "<Geometry xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">"
+ arrSound + "</Geometry>";
vectorSound.Data = (Geometry)XamlReader.Load(xaml);