我正在使用路径创建特定形状。对所有路径进行分组的最佳方法是什么,以便稍后我可以在其他位置使用它们而无需重新定位路径?
任何建议都会很棒,谢谢!
答案 0 :(得分:3)
如果问题是关于只有一个填充和描边的复杂形状,则选项是仅使用一个带有多个PathGeometry Figures的Path实例。请参阅MSDN中的以下示例:
<Path Stroke="Black" StrokeThickness="1">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure IsClosed="True" StartPoint="10,100">
<PathFigure.Segments>
<PathSegmentCollection>
<LineSegment Point="100,100" />
<LineSegment Point="100,50" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
<PathFigure IsClosed="True" StartPoint="10,10">
<PathFigure.Segments>
<PathSegmentCollection>
<LineSegment Point="100,10" />
<LineSegment Point="100,40" />
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
答案 1 :(得分:1)
您可以在画布中进行分组,然后重新定位画布。 命名每个路径点将使您能够修改形状.... 您可以创建一个名为MyOwnShape的新类,该类继承Canvas类,然后为画布的每个点附加一个事件以进行拖放,以便修改形状。您也可以将您的内容放在烤架内,但是您无法以这种精确度定位您的形状。 如果我完全理解你想要实现的目标。你的课程应该像这样讨论
class MyOwnShapes : Canvas {
List<Path> myListOfPaths;
我希望这个例子对你有好处。
public void AddPath(Path myPath){
this.Children.Add(path);
myListOfPaths.Add(path), // this is used for your internal computation so it wont affect the effective drawin components.
}
http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh465055.aspx http://www.windowsphonegeek.com/tips/drawing-in-wp7-3-understanding-path-shapes