每个循环周期重绘到 silverlight 画布。是否可以?
任何帮助或指示将不胜感激。
基本上,我试图在一次“转弯”时移动或重新绘制一些椭圆到画布上。
目前,我可以单击按钮将椭圆渲染变换到画布内的新位置。每当我尝试多次执行此操作(例如,每次循环将 TranslateTransform X 和 Y 值递增 1)时,整个应用程序都会挂起。这是 RenderTransform 的问题吗?画布?主页线程?代码看起来很可靠,所以它为什么不能多次移动椭圆是个谜。
private void update()
{
int x = 0;
int y = 0;
while (turns <= 5)
{
TranslateTransform t = new TranslateTransform();
t.X = x + 1;
t.Y = y + 1;
// agent is a child element of a canvas.
agent.RenderTransform = t;
turns--;
}
}
any help or pointers would be massively appreciated.
Basically i'm trying to EITHER move OR redraw some ellipses to a canvas once a "turn".
At the moment I can click a button to RenderTransform the ellipse to a new location within the canvas. Whenever I try to do this more than once, for example, incrementing the TranslateTransform X and Y values by one each loop, the whole application hangs. Is this an issues which RenderTransform? The Canvas? The MainPage thread? The code looks solid, so its a mystery as to why it simply wouldnt move the ellipse more than once.
private void update()
{
int x = 0;
int y = 0;
while (turns <= 5)
{
TranslateTransform t = new TranslateTransform();
t.X = x + 1;
t.Y = y + 1;
// agent is a child element of a canvas.
agent.RenderTransform = t;
turns--;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 CompositionTarget 它会帮助您< br>
查看此示例
另一个很好的例子
像这样使用它:
并挂钩渲染事件
CompositionTarget.Rendering += Update;
编辑:如果您使用的是Canvas最好使用 Canvas.Left 和 Canvas.Top 附加属性
You can use CompositionTarget it will help you
look at this example
another good example
use it like this:
and hook the Rendering event
CompositionTarget.Rendering += Update;
Edit: If you are using Canvas it's better to use Canvas.Left and Canvas.Top attached properties