gpt4 book ai didi

c# - 为什么我不能在 XAML 中定义带有转换的几何图形?

转载 作者:行者123 更新时间:2023-11-30 13:31:51 24 4
gpt4 key购买 nike

我正在尝试创建一个 ResourceDictionary á la this answer包含 StreamGeometriesTransforms 集:

<ResourceDictionary>
<StreamGeometry x:Name="Chevrons">
<StreamGeometry.Transform>
<TranslateTransform X="20" Y="120"/>
</StreamGeometry.Transform>
M21.750001,94.749999 L34.000002,117.66218 30.625003,133.62501 17 [...]
</StreamGeometry>
</ResourceDictionary>

但是,我收到以下错误:

1: Cannot add content to an object of type "StreamGeometry".

2: TypeConverter syntax error encountered while processing initialization string '{PathData}'. Element attributes are not allowed on objects created via TypeConverter.

所以我尝试使用 PathGeometry 并得到了这个错误:

The specified value cannot be assigned to the collection. The following type was expected: "PathFigure".

有什么方法可以将转换应用于 XAML 代码中的几何图形?还是我只需要通过代码来完成?

最佳答案

你可以这样写:

<PathGeometry x:Key="Chevrons">
<PathGeometry.Transform>
<TranslateTransform X="20" Y="120"/>
</PathGeometry.Transform>
<PathGeometry.Figures>
M21.750001,94.749999 L34.000002,117.66218 30.625003,133.62501 ...
</PathGeometry.Figures>
</PathGeometry>

或者像这样:

<PathGeometry x:Key="Chevrons"
Figures="M21.750001,94.749999 L34.000002,117.66218 30.625003,133.62501 ...">
<PathGeometry.Transform>
<TranslateTransform X="20" Y="120"/>
</PathGeometry.Transform>
</PathGeometry>

关于c# - 为什么我不能在 XAML 中定义带有转换的几何图形?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18057155/

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