locked
Layout with cells for a game

    Question

  • Hello,

    I'm exploring MSDN documentation to find a suitable layout component for my needs, but with no luck. I would like to display several cells just link in "4 in a row" game and be able to get/set depending on their position on the grid.

    Do you have any advice?

    Thank you

    Tuesday, April 07, 2015 8:53 PM

Answers

  • > Looking forward to write some code and post something useful for the community.

    Please do post it! I am building a project where I need a similar 4x4 grid of items. I am currently using a regular GridView, but I'm having issues scaling that to work well on different screen sizes. I guess GridView is designed to efficiently/intelligently use the space it's given, but I want a 'dumber' grid of a forced size.


    Visit http://blog.grogansoft.com/ for Windows development fun.

    Actually I found this example which perfectly fit my situation with some tweaking

    http://garfoot.com/blog/2013/09/using-grids-with-itemscontrol-in-xaml/

    • Proposed as answer by pumpkinszwan Saturday, April 11, 2015 9:59 AM
    • Marked as answer by fillobotto Saturday, April 11, 2015 8:32 PM
    Friday, April 10, 2015 3:19 PM

All replies

  • There are several ways to do something like this. How is best will depend on your specific needs and game design.

    One way is to hard code a Grid control with however many rows and columns you need. You can either set cell positions directly or bind Grid.Row and Grid.Column properties.

    Another would be to create a custom panel for an ItemsControl which lays out a databound collections of cells in a grid.

    Tuesday, April 07, 2015 10:25 PM
    Owner
  • Actually a Grid wouldn't really fit my needs, or better, the code would become messy when I need to retrieve data from one cell, pass it to another one and handle all thier events.

    On the other side, I found interesting the solution with ItemsControl, so all the work to edit cells is made by ObservableCollection and binding.

    Looking forward to write some code and post something useful for the community.

    Thursday, April 09, 2015 6:50 PM
  • > Looking forward to write some code and post something useful for the community.

    Please do post it! I am building a project where I need a similar 4x4 grid of items. I am currently using a regular GridView, but I'm having issues scaling that to work well on different screen sizes. I guess GridView is designed to efficiently/intelligently use the space it's given, but I want a 'dumber' grid of a forced size.


    Visit http://blog.grogansoft.com/ for Windows development fun.

    Thursday, April 09, 2015 11:39 PM
  • > Looking forward to write some code and post something useful for the community.

    Please do post it! I am building a project where I need a similar 4x4 grid of items. I am currently using a regular GridView, but I'm having issues scaling that to work well on different screen sizes. I guess GridView is designed to efficiently/intelligently use the space it's given, but I want a 'dumber' grid of a forced size.


    Visit http://blog.grogansoft.com/ for Windows development fun.

    Actually I found this example which perfectly fit my situation with some tweaking

    http://garfoot.com/blog/2013/09/using-grids-with-itemscontrol-in-xaml/

    • Proposed as answer by pumpkinszwan Saturday, April 11, 2015 9:59 AM
    • Marked as answer by fillobotto Saturday, April 11, 2015 8:32 PM
    Friday, April 10, 2015 3:19 PM
  • Excellent, thanks for sharing that link, it's exactly what I needed too.

    Visit http://blog.grogansoft.com/ for Windows development fun.

    Saturday, April 11, 2015 10:00 AM