如何将.cpp中实例化的 PointCollection 传递给 .xaml 中的多边形
How do you pass a PointCollection instantiated in a .cpp to a Polygon in an .xaml?
我正在尝试使用用户提供的值在画布中绘制多边形。给定 .xaml 中的默认值,渲染很好。尝试从.cpp设置多边形点属性的值时出现问题。我是UWP的新手,我想我可以将点设置为等于PointCollection,但这似乎不起作用。任何帮助都会很棒
在 .xaml 中创建画布和多边形的位置
<Canvas x:Name="tCan" Margin="396,48,88,146">
<Polygon x:Name="triangle" Stroke="Black"/>
</Canvas>
将点集合传递到.cpp中的"多边形三角形"
By = 100 + a;
Cy = ((a * a) + (c * c) - (b * b)) / (2 * a);
Cx = sqrt((c * c - (Cy * Cy)));
PointCollection points;
points.Append(Point(100, 100));
points.Append(Point(100, By));
points.Append(Point(Cx, Cy));
triangle->Points = points;
最后一行抛出
"Windows::UI::Xaml::Shapes::Polygon::Points::set" cannot be called with the given argument list
argument types are: (Windows::UI::Xaml::Media::PointCollection)
object type is: Windows::UI::Xaml::Shapes::Polygon ^
错误意味着三角形的类型>点和点不对应,所以你应该转换点的类型:
By = 100 + a;
Cy = ((a * a) + (c * c) - (b * b)) / (2 * a);
Cx = sqrt((c * c - (Cy * Cy)));
PointCollection^ points = ref new PointCollection();
points->Append(Point(100, 100));
points->Append(Point(100, By));
points->Append(Point(Cx, Cy));
triangle->Points = points;
相关文章:
- 计算缩放多边形的比例,得到给定的多边形面积
- 将QGraphicsItem的移动区域限制在多边形区域内
- 重新排列单线以形成闭合多边形?
- 提升几何体:C++并集多个多边形
- 在 QT C++中绘制/操作多边形
- Maya API C++:从多边形获取材质
- 添加带有提升的多边形::p奥利贡不编译?
- 无法将运行时类绑定到 XAML T 必须是 WinRT 类型
- 使用 C++在 OpenGL 中对 3D 多边形进行纹理处理
- 使用 C++在 OpenGL 中移动自动旋转的 3D 多边形
- 如何使用增强::几何计算多边形的旋转固体体积?
- 从拉伸多边形构建多面体
- 使用提升几何缓冲区缩放多边形时的冗余折点
- C++ with XAML and UWP
- cgal多边形网格中的tet网格密度分级
- 如何绘制具有随机顶点数量的多边形并旋转它们
- 多边形裁剪 - 一点点详细说明
- 如何在"XAML for Windows Embedded (Compact 2013)"中切换图像
- 使用裁剪器库在线和多边形之间相交
- 如何将.cpp中实例化的 PointCollection 传递给 .xaml 中的多边形