gpt4 book ai didi

wpf - 在 WPF 中创建自定义形状(最好使用 Microsoft Expression Blend 4)

转载 作者:行者123 更新时间:2023-12-04 06:05:34 25 4
gpt4 key购买 nike

我想知道如何在 wpf 中绘制自定义形状(可能使用表达式 blend4),而不使用表达式 blend4 的笔功能。我想绘制下面提到的按钮,例如不规则形状的按钮。

最佳答案

我通常使用 Path绘制不规则形状的对象

例如,

<Path Stroke="Blue" Data="M 10 100 L 100 100 L 100 50 Z" />

将从 10,100 开始,画一条线到 100,100,然后再画一条线到 100,50,然后通过画一条线回到起点来关闭路径。

Example

您还可以使用小写字母来使用相对位置。例如,
<Path Stroke="Blue" Data="M 10 100 l 90 0 l 0 -50 Z" />

将绘制相同的形状,但使用相对路径。它将从 10,100 开始,沿 x 绘制一条 +90 的线,沿 y 绘制一条 0,然后另一条沿 x 为 0,沿 y 为 -50 的线。

同一行的较短版本将是
<Path Stroke="Blue" Data="M 10 100 h 90 v -50 Z" />

从 10,100 开始,水平 90,然后垂直 -50

我在构建路径时经常使用的一种资源是 this site ,其中列出了“几何迷你语言”的命令

当然,如果您愿意,也可以使用完整的 XAML 构建 Path 对象:
<Path Stroke="Blue">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="10,100" IsClosed="True">
<LineSegment Point="100,100" />
<LineSegment Point="100,50" />
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>

关于wpf - 在 WPF 中创建自定义形状(最好使用 Microsoft Expression Blend 4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8403482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com