Saturday, 15 June 2013

c# - WPF animating falling textblocks -



c# - WPF animating falling textblocks -

i'm making little math game in wpf , have "falling textblocks" contain multiplications have reply correctly before reach bottom of window.

currently looks this

what i'm doing right each textblock custom wpf command contains textblock represent look , textbox user can input reply expression. these generated within of 40x20 grid i'm using dispatchertimer continiously move them downwards grid until reach end of grid.

there 2 main problems approach:

the "effect" of falling isn't smooth, it's choppy, have been able improve fluidity of motion expanding grid downwards , decreasing interval @ dispatchertimer ticks @ best band-aid solution , can still tell motion mechanical. the other problem closely related first one, whenever textbox of these falling expressions focused falling becomes far far worse, slows crawl i'm guessing redrawing each , every command while having focus on textbox severely decreasing performance causing this.

anyhow because of this, seeking alternative way of doing this, preferably has easy utilize , easy integrate current code.

you can utilize canvas , alter position within dispatchertimer.

sample mockup grabbed on website, implementation dragging objects.

void ondragdelta(object sender, dragdeltaeventargs e) { canvas.setleft(mythumb, canvas.getleft(mythumb) + e.horizontalchange); canvas.settop(mythumb, canvas.gettop(mythumb) + e.verticalchange); }

here related question: here

here main draggable command article: here

c# wpf xaml

No comments:

Post a Comment