We all know that guy who is always gaming the system, it’s so irritating, you don’t quite know how he does it, and his career kind of sucks, but somehow he figures it out. Of course in software there are a lot of people who game the system, here is a clue: Software is about gaming the system. So let’s talk about creating a simple moving object thingie using XAML in the Windows Phone, because like my name, we must not mention Silverlight these days. Weird, Silverlight seems to be hanging around and the HTML 5 is trying to figure out just how does that Silverlight games the system. But let’s face it, unless Silverlight gangs up with XNA, it takes a lot of work to make Silverlight do games all by itself. Thanks to Jerry Nixon, http://blogs.msdn.com/jerrynixon, he doesn’t really need the hits, but take a look anyway, he has a bunch of really well written and excellent examples that I am tempted to use in my blogs. But I won’t, I refuse to increase the quality of this blog. (And we can mention Jerry Nixon’s name. Smile )
Moving an object on the screenOk, let’s take a look at a quick way to move an object on the screen. It might be cool to be able move an object without writing any code, unless you are writing articles, then it takes longer. This might be reason we don’t see much being done with codeless programming, maybe not. Open Expression, remove the existing Grid and stack panel, change the layout to canvas and add an image, I have a dorky stick figure and changed the background to an ugly green. Now we want to add a MouseDragElementBehavior (which is supported on the phone). Do this by: Changing to the Assets tab
Select Behaviors
Drag the MouseDragElementBehavior to the image, that’s it
Run your application and the image will be dragged by the mouse
Read more: Building games based on Silverlight and Expressions
QR: