c# - 在 Canvas 上绘制单个点的有效方法

标签 c# windows-phone-7

我正在寻找一种在 C# Canvas 上绘制单个点(带有颜色)的方法。 在android中我会做类似的事情

paint.Color = Color.Rgb (10, 10, 10);
canvas.DrawPoint (x, y, paint);

所以我想我可以在 Shape class 中找到它, 但它不在那里。我是不是遗漏了什么或者没有办法画出一个点?

在第二种情况下,推荐的画点方式是什么?在 HTML5 canvas 中存在类似的问题,人们使用 rectangles/circles 绘制点。 .

P.S. 一个类似标题的问题 Add Point to Canvas不回答它并进入“如何绘制形状”。

最佳答案

我刚刚为 UWP 遇到了同样的问题,我最终决定使用 Ellipse:

int dotSize = 10;

Ellipse currentDot = new Ellipse();
currentDot.Stroke = new SolidColorBrush(Colors.Green);
currentDot.StrokeThickness = 3;
Canvas.SetZIndex(currentDot, 3);
currentDot.Height = dotSize;
currentDot.Width = dotSize;
currentDot.Fill = new SolidColorBrush(Colors.Green);
currentDot.Margin = new Thickness(100, 200, 0, 0); // Sets the position.
myGrid.Children.Add(currentDot);

关于c# - 在 Canvas 上绘制单个点的有效方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19850291/

相关文章:

c# - 如何使用将帮助链接默认为 google.com 的构造函数创建子类?

C#自定义控件获取内部文本作为字符串

c# - 使用 NLog 作为翻转文件记录器

.net - 设计在多个移动平台上消费的服务

c# - Windows Phone 上的状态大小

silverlight - Windows Phone 7、MVVM、Silverlight 和导航最佳实践/模式和策略

c# - 带有 void * 的 PInvoke 与带有 IntPtr 的结构

c# - Dapper:帮助我运行具有多个用户定义的表类型的存储过程

silverlight - 如何在 Windows Phone 7 中禁用 ListBoxes/ScrollViewer 的过度滚动效果

silverlight - 将图像放在页面顶部而不干扰单击事件 Windows Phone