Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在画布比例中创建多个路径元素以适合其父级?_C#_Windows_Canvas_Path_Windows Store Apps - Fatal编程技术网

C# 如何在画布比例中创建多个路径元素以适合其父级?

C# 如何在画布比例中创建多个路径元素以适合其父级?,c#,windows,canvas,path,windows-store-apps,C#,Windows,Canvas,Path,Windows Store Apps,我在Illustrator中创建了一系列形状,并将它们导出到.ai文件中。当我在Blend for Visual Studio中导入此文件时,会得到如下结果: <Canvas x:Name="ManyPaths" Grid.Row="0"> <Path Data="F1M0,53.135L0.004,102.44 22.03,151.59 55.042,0z" Fill="#FF8B1A34" Height="151.59" Canvas.Left="0.017" St

我在Illustrator中创建了一系列形状,并将它们导出到.ai文件中。当我在Blend for Visual Studio中导入此文件时,会得到如下结果:

<Canvas x:Name="ManyPaths" Grid.Row="0">
    <Path Data="F1M0,53.135L0.004,102.44 22.03,151.59 55.042,0z" Fill="#FF8B1A34" Height="151.59" Canvas.Left="0.017" Stretch="None" Canvas.Top="182.406" Width="55.042"/>
    <Path Data="F1M0.003,34.152L22.027,49.15 0,0z" Fill="#FF991937" Height="49.15" Canvas.Left="0.02" Stretch="None" Canvas.Top="284.846" Width="22.027"/>
</Canvas>

这里有很多路径,为了简单起见,我不在这里一一列出。当放在一起时,它们会形成一个固定大小的矩形。我想使用我的应用程序顶部的这个矩形作为标题图像。我可以在Blend中调整Canvas元素的大小,但是我无法获得适合画布的集合路径,并且不能随画布一起调整大小。因为我是为各种尺寸的屏幕设计的,所以我希望标题图像能够缩放。我尝试过将它嵌套在网格中,但这不起作用

看起来C#中执行路径的传统方式是



我不确定是否有办法将第一种格式转换为第二种格式,但如果可能,我希望重用.ai文件,而不是从头开始重新创建它们。

无需转换为第二种格式。使用“数据”属性更简洁,而且通常更清晰

您可以将画布包装在一个容器中,以使其缩放到其容器。“拉伸”属性可以控制是否均匀拉伸或扭曲(可能需要均匀拉伸)


    <Path Grid.Row="1" Stroke="Black" StrokeThickness="2" Fill="Green">
        <Path.Data>
            <PathGeometry>
                <PathGeometry.Figures>
                    <PathFigure StartPoint="100,100">
                        <QuadraticBezierSegment Point1="165,25" Point2="225,100" />
                    </PathFigure>
                </PathGeometry.Figures>
            </PathGeometry>
        </Path.Data>
    </Path>
<Viewbox Stretch="Uniform" Grid.Row="0">
    <Grid x:Name="ManyPaths" >
        <Path Data="F1M0,53.135L0.004,102.44 22.03,151.59 55.042,0z" Fill="#FF8B1A34" Height="151.59" Canvas.Left="0.017" Stretch="None" Canvas.Top="182.406" Width="55.042"/>
        <Path Data="F1M0.003,34.152L22.027,49.15 0,0z" Fill="#FF991937" Height="49.15" Canvas.Left="0.02" Stretch="None" Canvas.Top="284.846" Width="22.027"/>
    </Grid>
</Viewbox>