gpt4 book ai didi

.net - 在 WPF 中画一个十字

转载 作者:行者123 更新时间:2023-12-04 13:08:44 24 4
gpt4 key购买 nike

我有一个 WPF 控件。

我需要在背景中有一个十字架,像这样:
enter image description here

之后,我可以在我的“交叉”背景上添加其他控件:
enter image description here

我应该如何绘制十字,知道当我调整控件大小时,十字应该跟随它的大小?

最佳答案

您可以使用单个 Path,而不是为布局引擎创建两个元素。元素:

<Path Data="M0,0L16,16M16,0L0,16" Stroke="Black" />
这是一个 16x16 “X” 符号:
enter image description here
您可以在 Data 中指定不同的大小。元素,或使用 ViewBox如果需要,将其缩放到其父大小。
请注意,线的末端是正方形的,并且略微超出 16x16 正方形:
enter image description here
如果你希望盒子正好是 16x16,你可以设置 Width="16" Height="16"Path , 剪裁线端:
enter image description here

关于.net - 在 WPF 中画一个十字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10145314/

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