locked
Moving Grid's elements RRS feed

  • Question

  • Hello,

    I hope someone can help me. I want to make table using Grid (or smth else?) and drag/move/drop elements between cells. So, I want to know where is each element now (elements — rectangles, i think; each rectangle equals cell size).

    For example: User opens my app and sees the field divided into squares. After that he drags element (they are located around of field; they can be placed in cells too, but user doesnt see that, because only main field (and its cells) have borders) to cell and (if it is empty) drops element to this cell. Then I can get coordinates (or smth similar) of this element in table.

    So, what I need to use for it? Grid? And how to move elements? I tried to use ManipulationDelta.. but dont know how I can fix element in cell and get its coordinates. 

    I try to create game Pentomino using XAML/C# for Windows 8.1. If you have some idea about it, please, help me and tell about.

    P. S.: Sorry for mistakes. I'm newbie in C#/XAML from Russia. Thank you for your patience.


    Thursday, October 10, 2013 3:03 PM

All replies

  • It's kind of a big question to ask on a forum.  The short answers are:

    1) Use a canvas since you can absolutely position any element on it.

    2) On the canvas, put your grid and remember what the exact coordinates are for each grid line

    3) Use ManipulationDelta to move the object as your cursor (or finger) moves. 

    4) When you hit ManipulationCompleted, you can decide which grid cell your object belongs inside and snap it to that  cell.


    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Friday, October 11, 2013 2:07 PM
    Moderator