gpt4 book ai didi

wpf - 以编程方式绘制路径

转载 作者:行者123 更新时间:2023-12-04 11:13:32 25 4
gpt4 key购买 nike

我正在学习在 WPF 中绘制形状。我想画一个 Path以编程方式,而不是通过 XAML。我不知道什么可以分配给 Data 属性。

Path p = new Path();
p.Data = ???

最佳答案

the sample in the MSDN :

//Add the Path Element
myPath = new Path();
myPath.Stroke = System.Windows.Media.Brushes.Black;
myPath.Fill = System.Windows.Media.Brushes.MediumSlateBlue;
myPath.StrokeThickness = 4;
myPath.HorizontalAlignment = HorizontalAlignment.Left;
myPath.VerticalAlignment = VerticalAlignment.Center;
EllipseGeometry myEllipseGeometry = new EllipseGeometry();
myEllipseGeometry.Center = new System.Windows.Point(50,50);
myEllipseGeometry.RadiusX = 25;
myEllipseGeometry.RadiusY = 25;
myPath.Data = myEllipseGeometry;
myGrid.Children.Add(myPath);

是线路 myPath.Data = myEllipseGeometry;你正在寻找的。只需为其分配一个 Geometry 对象。

关于wpf - 以编程方式绘制路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8378252/

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